Thread View: comp.lang.misc
1 messages
1 total messages
Started by ozan s. yigit
Thu, 22 Feb 1996 23:58
Re: Readable Perl (was: Re: Relative Speed of Perl vs. Tcl vs. C)
Author: ozan s. yigit
Date: Thu, 22 Feb 1996 23:58
Date: Thu, 22 Feb 1996 23:58
36 lines
1486 bytes
1486 bytes
some people seem to dislike tiny code examples, which seems rather
strange: in capable hands, they speak volumes. it is true that not
every posting includes such a gem, but i think there is room for even
the good old fib. on the essay side, very few languages come with the
type of tour-de-force tutorial [1] sather people have been able
to put together, not sure why...
anyway, just for the kicks, here is one fib due to kent dbybig. enjoy.
;;; fib with peano arithmetic (using numbers) with call/cc
(define addc
(rec addc
(lambda (x y k)
(if (zero? y)
(k x)
(addc (1+ x) (1- y) k)))))
(define fibc
(rec fibc
(lambda (x c)
(if (zero? x)
(c 0)
(if (zero? (1- x))
(c 1)
(addc (call/cc (lambda (c) (fibc (1- x) c)))
(call/cc (lambda (c) (fibc (1- (1- x)) c)))
c))))))
oz
---
[1] Michael Philippsen
Sather 1.0 Tutorial
International Computer Science Institute TR-94-062
December 1994
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads