Kip, Here are some samples:
Not quite what you wanted from me:
fibla=:[: +/\ |.
recur=:^:
n=: 13 :'0{"1 fibla recur (i.y) ] 1 1'
n 12
1 1 2 3 5 8 13 21 34 55 89 144
Raul's and my rendition of his version:
fib=:,+/@{.~&_2
fib2=:,_2 ([: +/ {.)]
fib recur (i.6)]1 1
1 1 0 0 0 0 0
1 1 2 0 0 0 0
1 1 2 3 0 0 0
1 1 2 3 5 0 0
1 1 2 3 5 8 0
1 1 2 3 5 8 13
fib2 recur (i.6)]1 1
1 1 0 0 0 0 0
1 1 2 0 0 0 0
1 1 2 3 0 0 0
1 1 2 3 5 0 0
1 1 2 3 5 8 0
1 1 2 3 5 8 13
I'm not sure about Raul's arith:
arith=: ] , +&{:
arith recur (i.6)]1 1
1 1 0 0 0 0 0
1 1 1 0 0 0 0
1 1 1 1 0 0 0
1 1 1 1 1 0 0
1 1 1 1 1 1 0
1 1 1 1 1 1 1
Raul's e takes lots of space and I can't seem to change the precision for
6 to 3 or 4 in j7.
e recur (i.3)] 1 1
1 1 0 0 0 0 0 0
1 1 0.5 0.5 0 0 0 0
1 1 0.5 0.5 0.0416667 0.0416667 0.00260417 0.00260417
e=: ] , [ (^t.@] * ^) #@]
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of km
Sent: Monday, December 24, 2012 5:58 PM
To: [email protected]
Subject: Re: [Jprogramming] Recurring holiday amusement
OK, conjunction
recur =: 2 : '(, u)^:n'
and you can still write the verbs. As you can see, the result of recur
applies u to the current list and appends that result to the current list,
repeating this operation n times. Just about any list can be produced by
designing an appropriate u . Your assignment is to design verbs fib, arith,
and e . Kip Murray
Sent from my iPad
On Dec 23, 2012, at 9:00 PM, km <[email protected]> wrote:
> Write a conjunction recur and verbs fib, arith, and e that do the
following
>
> fib recur 5 [ 1 1 NB. five additional terms of Fibonacci sequence
> 1 1 2 3 5 8 13
> 0.5&arith recur 5 [ 3
> 3 3.5 4 4.5 5 5.5
> 1&e recur 5 [ ''
> 1 1 0.5 0.166667 0.0416667
> +/ 1&e recur 10 [ ''
> 2.71828
> +/ _1&e recur 10 [ ''
> 0.367879
> ^ 1 _1
> 2.71828 0.367879
>
> Conjunction recur helps create "recursive" lists.
>
> Kip Murray
>
> Sent from my iPad
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm