|
Tuesday, March 02, 2004 |
Meme is an IRC channel browser written in Common Lisp by Kevin Rosenberg. It logs various channels from freenode and allows viewing, searching and graphing details about those channels.
3:53:03 PM
|
|
From Lambda the Ultimate
comes a pointer to some arcticles on implementing a 'range' macro in
Scheme, and how this allows you to write code in Scheme that is very
similar to Python's 'for' construct.
The 'range' macro allows you to create a range of numbers and perform
actions on that range. It is efficient in that it doesn't construct a
termporary list to create the range. Code that uses the range does not
need to be written to have knowledge of it. For example, take the
factorial function:
(define (fact n) (if (<= n 0) 1 (* n (fact (- n 1)))))
The following code will display the factorials of numbers 1 through to 5 using range:
(breset r (begin (display (fact (range r 1 5))) (newline)))
Nesting, breaking, continuing, etc is all supported. For more about 'range' see Oleg's Usenet posting. For further examples and how it can be used to emulate Python's 'for' operator, Oleg has another posting exanding on it.
1:30:39 PM
|
|
© Copyright 2005 Chris Double.
|
|
|