Replace the f in the definition of g with the definition of f.

   g=: 13 :'(13 : ''y,+/_2{.y'')^:(<:y) 1'

   g

+-+-+---------------------------+

|3|:|(13 : 'y,+/_2{.y')^:(<:y) 1|

+-+-+---------------------------+


Okay, it looks kind of weird to include a definition within a definition.


The conjunction power is just like the ^: except the operands are swapped.
It's the same as

   (f^:13)1 1

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610


The ^: conjunction is something that would come later in learning J and
defining "power" instead avoids having to deal with how ^: works for a
while. And swapping the arguments avoids the parentheses. Kids might think
it looks cool.


And, of course, having the 1 1 as an argument as well will get somebody in
the class might try something like:

   7 power f 1 3

1 3 4 7 11 18 29 47 76

   7 power f 1 1.1

1 1.1 2.1 3.2 5.3 8.5 13.8 22.3 36.1

   7 power f 1 _1

1 _1 0 _1 _1 _2 _3 _5 _8


All of these go to the golden ratio as a limit.

   %~/_2{.20 power f 1 1

1.61803

   %~/_2{.20 power f 1 3

1.61803


Something else for the kids to think about.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to