Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #16968

Recursive Lists

From Arnold Doray <invalid@invalid.com>
Newsgroups comp.lang.forth
Subject Recursive Lists
Date 2012-11-02 08:48 +0000
Organization A noiseless patient Spider
Message-ID <k701di$9k6$1@dont-email.me> (permalink)

Show all headers | View raw


Dear Forthers, 

I have made a tiny extension to Mini (mini.terraweather.com) so 
you can now define recursive lists using the words {: and ;}

For example, an infinite list generating the Fibonacci series would be

{:
dup 1 cons 0 cons
dup tail ' + zipwith
;}

.S 
<1> com.terraweather.mini.seq.ZipWith@1f8b81e3 ok

1000 take .list
1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 
17711 ... 

Haskell has something similar:

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

Cheers,
Arnold

Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread


Thread

Recursive Lists Arnold Doray <invalid@invalid.com> - 2012-11-02 08:48 +0000

csiph-web