Re: [Jprogramming] print an array

2017-09-30 Thread Devon McCormick
The "calendar" verb from J's "stdlib" has an optional left argument that allows you to specify the starting day of the week: calendar=: 3 : 0 0 calendar y : a=. ((j<100)*(-100&|){.6!:0'')+j=. {.y b=. (a-x)+-/<.4 100 400%~<:a r=. 28+3,(~:/0=4 100 400|a),10$5$3 2 r=. (-7|b+0,+/\}:r)|."0 1 r(]&:>:*"1

Re: [Jprogramming] print an array

2017-09-29 Thread Jimmy Gauvin
Is a two-step process too ugly? ​ a​ =:6 7$ 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 1011 ​ ​ 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 ​ (a='_')}' ',:~a=: ":(a=0)}_,:~a​ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3

Re: [Jprogramming] print an array

2017-09-28 Thread David Lambert
osts. On 09/28/2017 08:00 AM, programming-requ...@forums.jsoftware.com wrote: Date: Wed, 27 Sep 2017 17:57:54 +0200 From: Rudolf Sykora To:programm...@jsoftware.com Subject: [Jprogramming] print an array Message-ID: Content-Type: text/plain; charset="UTF-8" Hello, I have an ar

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 28 September 2017 at 15:43, Raul Miller wrote: > But, yes, this works: > >r=: , LF,.~": _7 ]\ 0 >. i.&.(+&5) 32 So this is much in the way I wanted it at the very begining. Thanks. Ruda -- For information about J foru

Re: [Jprogramming] print an array

2017-09-28 Thread 'Mike Day' via Programming
Yes,  you're right in a way about @: ,  but I'd skipped defining a verb to do the job. What I had in mind,  but didn't explicitly show,  was something like      remz =: ($$rplc & (' 0';' ')) @ ":    NB. @  also works ok! so allowing     remz a etc. And yes,  the $$ restores the shape of the rave

Re: [Jprogramming] print an array

2017-09-28 Thread Raul Miller
I did not write stringreplace, so am not prepared to discuss its implementation tradeoffs. But, yes, this works: r=: , LF,.~": _7 ]\ 0 >. i.&.(+&5) 32 r 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 r rpl

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 28 September 2017 at 14:50, Raul Miller wrote: > Another way to work around this problem would be to use stringreplace"1 > >r=: _7 ]\ 0 >. i.&.(+&5) 32 >(":r) rplc"1 ' 0';' ' Ok. Thanks. So is there a good reason for txt=. ,y in stringreplace? Or, can the whole of r be represented as

Re: [Jprogramming] print an array

2017-09-28 Thread Raul Miller
If you look at the definition of stringreplace, the first line is txt=. ,y So it's working with ,r Another way to work around this problem would be to use stringreplace"1 (Though, personally, I prefer rplc over stringreplace, because that leaves more room for other stuff on my lines. Also, ne

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 27 September 2017 at 19:13, 'Mike Day' via Programming wrote: >($$rplc & (' 0';' ')) @: ": a Yes. (I guess the @: is unnecessary here, right?) I actually had tried something similar first: (' 0';' ') stringreplace ":r which, however, yielded 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1516 17 18

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 27 September 2017 at 19:44, chris burke wrote: > a=. (a<32) * a=. 0 >. _5 + i.6 7 > > > 'b<>3.0' (8!:2) a Thanks, this is probably the expected form, though I still have to find out, what exactly it does. :)) Ruda ---

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 28 September 2017 at 01:21, Roger Hui wrote: > If you are making a calendar you may find the following of interest: > http://www.jsoftware.com/papers/eem/qq101.htm . It's APL but the ideas > translate pretty readily into J. Thanks. Actually, I am not making a calendar :), I just wanted to see

Re: [Jprogramming] print an array

2017-09-28 Thread Rudolf Sykora
On 28 September 2017 at 01:09, Devon McCormick wrote: > Assuming a is a numeric matrix: > >a=. ":a >(a='0')}a,:' ' >1 > 2 3 4 5 6 7 8 > 9 1 11 12 13 14 15 > 16 17 18 19 2 21 22 > 23 24 25 26 27 28 29 > 3 31 > > see the missing zero in 10, 20, 30; isolated ze

Re: [Jprogramming] print an array

2017-09-27 Thread robert therriault
And there is a calendar verb in the standard library that may be able to produce what you want. calendar 2017 4 ┌─┐ │ Apr │ │ Su Mo Tu We Th Fr Sa│ │1│ │ 2 3 4 5 6 7 8│ │ 9 10 11 12 13 14 15│ │ 16 17 18 19 20 21 22│ │ 23 24 25 2

Re: [Jprogramming] print an array

2017-09-27 Thread Roger Hui
If you are making a calendar you may find the following of interest: http://www.jsoftware.com/papers/eem/qq101.htm . It's APL but the ideas translate pretty readily into J. On Wed, Sep 27, 2017 at 8:57 AM, Rudolf Sykora wrote: > Hello, > > I have an array of integers > > 0 0 0 0 0 0 1

Re: [Jprogramming] print an array

2017-09-27 Thread Devon McCormick
Assuming a is a numeric matrix: a=. ":a (a='0')}a,:' ' 1 2 3 4 5 6 7 8 9 1 11 12 13 14 15 16 17 18 19 2 21 22 23 24 25 26 27 28 29 3 31 On Wed, Sep 27, 2017 at 1:44 PM, chris burke wrote: > a=. (a<32) * a=. 0 >. _5 + i.6 7 > > > 'b<>3.0' (8!:2) a

Re: [Jprogramming] print an array

2017-09-27 Thread chris burke
a=. (a<32) * a=. 0 >. _5 + i.6 7 'b<>3.0' (8!:2) a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 On Wed, Sep 27, 2017 at 10:13 AM, 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > Assuming a

Re: [Jprogramming] print an array

2017-09-27 Thread 'Mike Day' via Programming
Assuming a is an integer array, not character, how about:    ($$rplc & (' 0';'  ')) @: ": a    1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ? (Leading zeros should only appear for zero itself). Though isn't there a print/format fun

Re: [Jprogramming] print an array

2017-09-27 Thread Brian Schott
a =: 0 : 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 ) $b =: ".;._2 a 6 7 >,each ;/(3&":`(' '"_))@.(0=])"0"1 b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

[Jprogramming] print an array

2017-09-27 Thread Rudolf Sykora
Hello, I have an array of integers 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 and I want to have it printed (to a string, say) without the zeros. I.e, I want to replace each isolated 0 with a space. How can I do i