| Author |
loop action with scheme
|
|
| isaac2004 2006-04-07, 7:04 pm |
| hi im new to scheme and was wondering if it is possible to create a
looping action with scheme. say the prompt is entered something like
this
(make-list 7 '())
this asks the to create a list with 7 of () so something like this
(() () () () () () ())
how would you go about making a scheme function to create this action
| |
| Thomas Hafner 2006-04-07, 7:04 pm |
| "isaac2004" <isaac_2004@yahoo.com> wrote/schrieb <1144452780.481277.87260@i40g2000cwc.googlegroups.com>:
> how would you go about making a scheme function to create this action
(define (make-list n el)
(let loop ((n n) (a '()))
(if (< 0 n)
(loop (- n 1) (cons el a))
a)))
| |
| Jens Axel Søgaard 2006-04-07, 7:04 pm |
| isaac2004 wrote:
> hi im new to scheme and was wondering if it is possible to create a
> looping action with scheme. say the prompt is entered something like
> this
> (make-list 7 '())
> this asks the to create a list with 7 of () so something like this
> (() () () () () () ())
> how would you go about making a scheme function to create this action
See
<http://schemecookbook.org/view/Cook...opingConstructs>
--
Jens Axel Søgaard
|
|
|
|