[plt-scheme] Implementing constructors for environment interface
> #lang scheme
>
> (require htdp/testing)
>
> (define (extend-env* vars vals f)
> (lambda (var)
> (if (member var vars)
> (foldl (lambda (var* val* r) (if (eq? var* var) val* r))
> (gensym) vars vals)
> (f var))))
>
> (define new-stack (extend-env* '(var1 vark) '(val1 valk) (lambda
> (x) 10)))
>
> (check-expect (new-stack 'var1) 'val1)
> (check-expect (new-stack 'vark) 'valk)
> (check-expect (new-stack 'x) 10)
>
> (test)
On Feb 10, 2009, at 9:10 AM, aditya shukla wrote:
> I have an interface , how can i implement a constructor extend-env*
> using a list representation such that
>
> (extend-env* (var1 ... vark) (val1 ... valk) f ) = g,
>
> where g(var) =vali if var = vari for some i such that 1 ² i ² k
> f (var) otherwise
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme