Cliff, I'm never quite sure where I'm going! I'm wallowing around somewhere
between 4th and 5th grade and trying to make students understand big ideas.
So: Here is my "Slinky"
load 'plot'
do=: 13 :'({.y)+(i.{:>:y)*(--/}:y)%{:y'
t=:do 0 10 1000
sin=:1&o.
cos=:2&o.
'pensize 2;aspect 1'plot (sin t);cos t NB. TWO poolar circles
'pensize 2;aspect 1'plot t;(sin t);cos t NB. Slinky from two circles over time
If I have a Fibonacci sequence (as simple as possible) then I should be able to
make a "Golden Spiral" in 2-D. But if I could start with a 1 inch cube, could I
turn my slinky into a "Snail Shell Spiral"
I have found the forum to be the most fun when a problem hatches and develops
with ideas from everywhere.
A short take on where I think I may be headed. Now I'll look at what you sent.
Cheers. Linda
-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf
Of Cliff Reiter
Sent: Monday, February 27, 2017 8:17 PM
To: [email protected]
Subject: Re: [Jprogramming] Explicit fib
Hi Linda,
Were you just looking for the list version of the sequence? Same spirit as fib2:
mp=:+/ . *
]W=:*i.2 2
0 1
1 1
fib3=:3 : '{: |: W&mp^:(i.y) 0 1'
fib3 10
1 1 2 3 5 8 13 21 34 55
Best, Cliff
On 2/27/2017 10:31 AM, Linda A Alvord wrote:
> I like fib2 and things were going well but I hit a snag:
>
> ]W=:*i.2 2
> 0 1
> 1 1
> mp=:+/ . *
> fib2=:3 : '{. W&mp^:y 0 1'
> ". }:, (14 5$'(fib2'),"1 (' ',"1 ' ',"1 ":,.>:i.14),"1 '),'
> 1 1 2 3 5 8 13 21 34 55 89 144 233 377
>
> fib3=: 13 :' ". }:, ((y,5)$'(fib2'),"1 (' ',"1 ' ',"1 ":,.>:i.y),"1 '),''
> |domain error: fib2
> | {.W&mp ^:y 0 1
>
> It doesn't like the fact that that the fib2 should still be just letters.
>
> It was fun anyway. Linda
>
> -----Original Message-----
> From: Programming [mailto:[email protected]] On
> Behalf Of Cliff Reiter
> Sent: Sunday, February 26, 2017 2:27 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Explicit fib
>
> Here are a couple approaches:
> First, make a list, then take the last thing in it.
>
> fib_list=:3 : 0
> z=.0 1
> for. i.y-1 do.
> z=.z,+/_2{. z
> end.
> if. y>0 do. z else. 0 end. NB. this only used to make fib_list 0
> correct
> )
>
> fib_list 10
> 0 1 1 2 3 5 8 13 21 34 55
>
> fib=:{:@fib_list
>
> fib 10
> 55
>
> fib 0
> 0
>
> Or use matrix multiply
>
> mp=:+/ . *
>
> ]W=:*i.2 2
> 0 1
> 1 1
>
> W takes one fib pair to the next one
> W mp 13 21
> 21 34
>
> fib2=:3 : '{. W&mp^:y 0 1'
>
> fib2 10
> 55
>
> NB. It even works correctly for negative integers
>
> fib2 _2
> _1
>
> ----------------------------------------------------------------------
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm