> Mr. Bron wrote:
>          3 5 (0 *./@:= |/) i. 20
>       1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
>
>          3 5 (] #~ 0 *./@:= |/) i. 20
>       0 15
>
>   
Thank you very much for that step-by-step approach Mr. Bron, it really 
made it
quite easy to follow. Just for the sake of correctness your program however
produces an incorrect result, I think because of your application of 
LCM, so the
correct result would come from

+/~., 3 5 (] #~ 0 ~.@:= |/) i. 20
78

Where yours returned 15, or

 +/~., 3 5 (] #~ 0 ~.@:= |/) i. 1000
233168

I think I would be able to write something like that up myself now, 
because its
analogous to how I visualize it mentally, I'm a bit surprised that the 
compiler knows
where to apply the zero...


> You might be interested in the Fibonacci sequence essay on our Wiki [2].
>
>   
I think it was the frontpage of the essays which said "More text than 
code", but I find the
relationship between the amounts very uneven. Reading through the 
examples in
Fibonacci sequences, I came out more lost than I was going in.

> To break this down, right-to-left (as J verbs are read):
>
>      "0    NB.  For every number individually,
>      @:":  NB.  get its decimal string representation
>      -:|.  NB.  and tell whether it matches (-:) its own reverse (|.)
>   
Aha. I almost makes a lot of sense. :)
> However, for the beginning, I suggest you eschew tacit programming and
> function composition (@: &: etc).  
Is it not just a matter of learning the order of evaluation, composition 
of trains, etc and adding
that to your knowledge of functions? Right now I don't feel like I'm 
being tripped up by the composition
but rather my lack of experience using the many operators/functions. 
Personally I would hate to have to
take a step 'back' and learn it in those two phases - do you feel 
strongly about it?

Many thanks (once again),
Lau
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to