[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: accumulator generator
> (define (foo n)
> (lambda (i) (set! n (+ n i))))
In Forth, I believe this would be:
: foo create , does> +! ;
and used (for n=17,i={1,2,3...}) like:
17 foo bar
1 bar
2 bar
3 bar ...
I don't know Forth well enough to say how
one gets the incremented value back, but
then, I don't know Scheme well enough to
say how one would there, either.
Perhaps we want the following?
: foo create , does> tuck +! @ ;
-Dave
This exercise is interesting, but may
be moot; it makes judgements based on
the simplest, abstract, case of what
is often expressed as:
(define (fsm state)
(lambda (update) (next-state! state update)))
: fsm create init-state
does> next-state ;
To be able to express trivial problems
elegantly is nice, but I don't think a
working language should lose marks for
overhead unless it remains significant
even for practical problems.