Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Roger Hui
SP=: ' ' b2o=: }.@(( 'x' (b2o -: b2q) x 1 timer 'b2o x' 0.388007 timer 'b2q x' 0.262082 On Thu, Sep 6, 2012 at 4:07 PM, Ian Clark wrote: > Quite right, Raul. And strings containing newlines do matter to me. A lot. > > I confess I only threw in bpv as a bit of a joke. It relies

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Gilles Kirouac
The first time I saw ;: ^: _1 was in a solution offered by Ewart Shaw a long time ago (before 1998, since it is not in the current archives). My reply was: Wow! One may be using J for years and still someday discover such pearls. ~ Gilles --

[Jprogramming] deoptim and lbfgs minimization

2012-09-06 Thread Piet de Jong
I 'm trying to use the "deoptim" math addon package. However can't figure it out.Tried the following trite example to understand how things work. NB. Minimize the sum of squares within the range _3 to 3 require 'math/deoptim' ssq=:+/@*: deoptim 'ssq';_3 3 This fails for a

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread bill lam
As I understand it, the short hand load'foo/bar' is intended to load an addon package, and a package is fixed at the 2nd level of the folder tree under ~addons. If it can work with other variations under ~addons, it might be a bug. Птн, 07 Сен 2012, Ian Clark писал(а): > @Raul @Devon > > Yes, t

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Ian Clark
@Raul @Devon Yes, thank you both, your thoughts have helped me a lot. Though I guess I knew most of that already. But what was bugging me was this one simple thing... My proposed addon 'misc/zulu' is meant for raw beginners. Consequently I want them to "require" it in as easy a way as possible.

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Raul Miller
On Thu, Sep 6, 2012 at 7:07 PM, Ian Clark wrote: > (I suspect ;:inv will eventually let me down too, but I haven't fooled it > yet!) I have not been able to make it misbehave (though I've been too lazy to look up the c source for it, which would probably be the efficient thing to do). ;:inv

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
Quite right, Raul. And strings containing newlines do matter to me. A lot. I confess I only threw in bpv as a bit of a joke. It relies on 5!:5 converting boxed z to... <;._1 ' alpha bravo charlie' which it doesn't always. In fact, it returns your example without change ... z123=: '1';'2';'3'

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Raul Miller
Note that bpv would also have problems with boxed strings containing spaces, and even worse problems with boxed strings containing newlines. (It's not clear, though, if strings containing newlines matter to you.) -- Raul On Thu, Sep 6, 2012 at 6:39 PM, Ian Clark wrote: > Right you are. > > Wha

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
Right you are. What I really want (but haven't said) is the fastest versions of b2o (boxed-to-open-string) and b2f (boxed-to-LF-separated-string), where b2f is b2o with ' ' (-:SP) replaced with LF. I think I've got them now, thanks to everyone. BTW solutions involving deb aren't general enough,

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Raul Miller
bpv '1';'2';'3' '3 -- Raul On Thu, Sep 6, 2012 at 6:32 PM, Ian Clark wrote: > Here's a really perverse solution ... >bpv=: 3 : '}:8}.5!:5<''y''' >bpv z > alpha bravo charlie > > I've played with Roger's suggestion: }: ; z,&.> ' ' > to get: >rrb=:[: }.@; SP ,&.> ] > (where

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
Here's a really perverse solution ... bpv=: 3 : '}:8}.5!:5<''y''' bpv z alpha bravo charlie I've played with Roger's suggestion: }: ; z,&.> ' ' to get: rrb=:[: }.@; SP ,&.> ] (where: SP=: ' ') I've also done some repeated timings of solutions to-date, with a longer z of 1000 atom

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Raul Miller
I prefer ;:inv z But note that deb,' ',.>z would work. (J6 users need require'strings' before this can work.) FYI, -- Raul On Thu, Sep 6, 2012 at 6:21 PM, Ian Clark wrote: > Yes, but we need a string. > You can ravel the 2D array to get a string, viz: >,> z > but it gives you a va

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
Yes, but we need a string. You can ravel the 2D array to get a string, viz: ,> z but it gives you a varying number (0 or more) of separating spaces. On Thu, Sep 6, 2012 at 10:50 PM, km wrote: > > 'alpha';'bravo';'charlie' > alpha > bravo > charlie > > I'm resending because the echo from

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread km
> 'alpha';'bravo';'charlie' alpha bravo charlie I'm resending because the echo from Jsoftware to my iPad was incorrect. Hope this one shows my solution was to open the list of boxes. Sent from my iPad On Sep 6, 2012, at 4:32 PM, km wrote: >> 'alpha';'bravo';'charlie' > alpha >

Re: [Jprogramming] drop ith elements

2012-09-06 Thread Zsbán Ambrus
On 9/5/12, pascha wrote: > I have a huge matrix (say n x m) and I want to drop the columns numbered > with > mutiple of 3 (i.e. 3th, 6th, 9th,..) > how can I achieve that? Roger already showed you a good way, but let me show some others. Let me use this matrix as an example input. ]d =: (?.6

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread km
> 'alpha';'bravo';'charlie' alpha bravo charlie (shape 3 7) Sent from my iPad On Sep 6, 2012, at 11:38 AM, Ian Clark wrote: > Kindergarten class... > > I have a list of boxed literals... > z=: 'alpha' ; 'bravo' ; 'charlie' > > I want to flatten it to a literal, but with spaces betw

Re: [Jprogramming] concatenate and reshape matrix

2012-09-06 Thread Eric Iverson
a,:b NB. note differences between , ,. and ,: On Thu, Sep 6, 2012 at 5:23 PM, pascha wrote: > > Maybe it's too simple but I do have problem. I have two matrix with the same > size but with different values, i.e.: > i.3 4 > 0 1 2 3 > 4 5 6 7 > 8 9 10 11 > and > 1+ i.3 4 > 1 2 3 4 > 5 6 7

[Jprogramming] concatenate and reshape matrix

2012-09-06 Thread pascha
Maybe it's too simple but I do have problem. I have two matrix with the same size but with different values, i.e.: i.3 4 0 1 2 3 4 5 6 7 8 9 10 11 and 1+ i.3 4 1 2 3 4 5 6 7 8 9 10 11 12 now both have size of 3 x 4. How would you concatenate them to one matrix to have the size of 2 x 3

[Jprogramming] concatenate and reshape matrix

2012-09-06 Thread pascha
Maybe it's too simple but I do have problem. I have two matrix with the same size but with different values, i.e.: i.3 4 0 1 2 3 4 5 6 7 8 9 10 11 and 1+ i.3 4 1 2 3 4 5 6 7 8 9 10 11 12 now both have size of 3 x 4. How would you concatenate them to one matrix to have the size of 2 x 3

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Raul Miller
On Thu, Sep 6, 2012 at 3:39 PM, Ian Clark wrote: > Re-reading this thread I think my terse reply could be taken for curt. > I apologise if this has given offence. No offense taken. Disorientation on the other hand? I have been taking some of that... > 1. Is there a recommended way of doing thi

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
As soon as I saw ;:inv it rang a bell... And, hey presto! ... http://www.jsoftware.com/pipermail/programming/2012-January/026347.html PATIENT: I keep on forgetting what I've just said! DOCTOR: How long's this been going on? PATIENT: How long's what been going on? Sorry, folx. :-\ On Thu, Sep 6,

Re: [Jprogramming] Print Custom Alphabet

2012-09-06 Thread bob therriault
Thanks Devon - Nice work. Cheers, bob ps. my apologies for not acknowledging your original idea of a joint submission. I have added your name to the author list through your participation with the explanation. bt On 2012-09-06, at 1:13 PM, Devon McCormick wrote: > Thanks, Bob. > > I just add

Re: [Jprogramming] Print Custom Alphabet

2012-09-06 Thread Devon McCormick
Thanks, Bob. I just added an explanation of the code that's only slightly incomplete - I didn't explain how the "dot" gives a matrix and I'm not up on the nuances of Unicode so I didn't explain the "2#" on the table of numbers. On Thu, Sep 6, 2012 at 1:30 PM, bob therriault wrote: > Hey everyone

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Ian Clark
@Raul Re-reading this thread I think my terse reply could be taken for curt. I apologise if this has given offence. Let me re-engage with your reply, this time more carefully. * * * * * My question had two parts. Paraphrasing them: 1. Is there a recommended way of doing this, viz offerring and

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Devon McCormick
I do something like this now using the first method you propose: I set a global flag. In the script, I check for the existence of this flag and set it (as a local variable) to a default value if it isn't defined. I don't think it's that yukky. -- Devon McCormick, CFA ^me^ at acm. org is my pref

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Ric Sherlock
That's the nicest for this usage. joinstring (in the strings script j602, loaded at boot in j701) is useful for occasions when you want to join with one or more other chars. ',' joinstring z alpha,bravo,charlie ')(' joinstring z alpha)(bravo)(charlie On Fri, Sep 7, 2012 at 4:44 AM, Aai wro

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Raul Miller
On Thu, Sep 6, 2012 at 12:43 PM, Ian Clark wrote: > No I'm not sure I can't solve it some other way. That's why I'm asking. > >> Why? > > Why shouldn't I want an addon that can be loaded in different modes? > (Forget about "require" for now.) It's complex. If people use your misc/zulu, and one p

Re: [Jprogramming] Print Custom Alphabet

2012-09-06 Thread bob therriault
Hey everyone, I just posted the 43 character solution on the contest site. http://codegolf.stackexchange.com/questions/7036/print-custom-alphabet/7192#7192 Authors listed as: AlvordBossCerovskiCyrEllerHuiLambertMillerQuintanaSchottSherlockTaylorTherriault Let me know if anyone was missed and I

Re: [Jprogramming] (no subject)

2012-09-06 Thread chris burke
There was a spam from this account before, and no other messages from it. We have our own mailman forums, so can reinstate if need be. On Thu, Sep 6, 2012 at 3:08 PM, Ian Clark wrote: > A note of caution: it might be spam sent from a hijacked account. Been > happening a lot recently. > > Do we h

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Roger Hui
Nice. On Thu, Sep 6, 2012 at 9:44 AM, Aai wrote: > >;: inv z > alpha bravo charlie > > On 06-09-12 18:38, Ian Clark wrote: > >> Kindergarten class... >> >> I have a list of boxed literals... >> z=: 'alpha' ; 'bravo' ; 'charlie' >> >> I want to flatten it to a literal, but with spaces b

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Aai
;: inv z alpha bravo charlie On 06-09-12 18:38, Ian Clark wrote: Kindergarten class... I have a list of boxed literals... z=: 'alpha' ; 'bravo' ; 'charlie' I want to flatten it to a literal, but with spaces between. (Variant: --with LF's). Raze (;) does indeed flatten the list...

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Ian Clark
No I'm not sure I can't solve it some other way. That's why I'm asking. > Why? Why shouldn't I want an addon that can be loaded in different modes? (Forget about "require" for now.) On Thu, Sep 6, 2012 at 5:10 PM, Raul Miller wrote: > On Thu, Sep 6, 2012 at 11:00 AM, Ian Clark wrote: >> Say I

Re: [Jprogramming] flattening boxed strings

2012-09-06 Thread Roger Hui
}: ; z,&.> ' ' alpha bravo charlie On Thu, Sep 6, 2012 at 9:38 AM, Ian Clark wrote: > Kindergarten class... > > I have a list of boxed literals... >z=: 'alpha' ; 'bravo' ; 'charlie' > > I want to flatten it to a literal, but with spaces between. (Variant: > --with LF's). > > Raze (;) do

[Jprogramming] flattening boxed strings

2012-09-06 Thread Ian Clark
Kindergarten class... I have a list of boxed literals... z=: 'alpha' ; 'bravo' ; 'charlie' I want to flatten it to a literal, but with spaces between. (Variant: --with LF's). Raze (;) does indeed flatten the list... ;z alphabravocharlie There's got to be a really neat extended Raze which

Re: [Jprogramming] load/require in different modes?

2012-09-06 Thread Raul Miller
On Thu, Sep 6, 2012 at 11:00 AM, Ian Clark wrote: > Say I want to release an addon called: misc/zulu. It has a choice of > modes to load it in. Why? The require mechanism assumes that once something is loaded that it does not have to be loaded again. It seems to me that offering load time optio

Re: [Jprogramming] duplicate row of matrix

2012-09-06 Thread Don Guinn
Is this what you want? a=:i.4 4 m=:1 1 0 0,:0 1 1 1 (8$m)*(2#a) 0 1 0 0 0 1 2 3 4 5 0 0 0 5 6 7 8 9 0 0 0 9 10 11 12 13 0 0 0 13 14 15 On Thu, Sep 6, 2012 at 8:28 AM, Devon McCormick wrote: > I'm not as conversant with rank as you are. To my way of thinking, >

[Jprogramming] load/require in different modes?

2012-09-06 Thread Ian Clark
Say I want to release an addon called: misc/zulu. It has a choice of modes to load it in. These modes set tracing or include optional verbs, builds system data differently etc. As it loads, zulu.ijs expects to see a system flag somewhere (call it: LOADMODE_j_) to run conditional code or set its ow

Re: [Jprogramming] duplicate row of matrix

2012-09-06 Thread Devon McCormick
I'm not as conversant with rank as you are. To my way of thinking, you want to multiply each row of "a" by each row of the multiplier: a *"1/2 4$ 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 2 2 1 1 0 0 0 0 3 3 1 1 0 0 0 0 4 4 This gives a 3-D result, which may be handy depending on what yo

Re: [Jprogramming] (no subject)

2012-09-06 Thread Ian Clark
A note of caution: it might be spam sent from a hijacked account. Been happening a lot recently. Do we have a procedure for victims to apologise / get reinstated? On Thu, Sep 6, 2012 at 11:11 AM, chris burke wrote: > Done. > > On Thu, Sep 6, 2012 at 9:51 AM, R.E. Boss wrote: > >> When is this g

Re: [Jprogramming] lint bug WAS: Lint control key for J602

2012-09-06 Thread Henry Rich
I don't consider that a false positive. Verbs that actually execute a 0 : 0 are unusual - much more likely is that the trailing ) of defineindex was omitted. To run lint on this verb, change y=. <;._2 (0 : 0) to a form not recognized as a noun-start, such as y=. <;._2 (0 : (0)) If you do th

Re: [Jprogramming] (no subject)

2012-09-06 Thread chris burke
Done. On Thu, Sep 6, 2012 at 9:51 AM, R.E. Boss wrote: > When is this guy removed from the forum? > > > R.E. Boss > > > > -Oorspronkelijk bericht- > > Van: programming-boun...@forums.jsoftware.com [mailto: > programming-boun...@forums.jsoftware.com] Namens Zack Brannigan > > Verzonden: w

Re: [Jprogramming] (no subject)

2012-09-06 Thread R.E. Boss
When is this guy removed from the forum? R.E. Boss > -Oorspronkelijk bericht- > Van: programming-boun...@forums.jsoftware.com > [mailto:programming-boun...@forums.jsoftware.com] Namens Zack Brannigan > Verzonden: woensdag 5 september 2012 21:44 > Aan: major...@csse.unimelb.edu.au; merc