Temporary Variable Assistance (Scheme) -



Temporary Variable Assistance (Scheme) -

i'm making random sentence generator using scheme (pretty big), , i'm having problem defining temporary variables. want create this:

<noun1> <verb1> <noun2> <but> <noun2> <verb1> <noun2> <also>

example: sharks eat fish, fish eat fish also. have word lists, , functions take word said list. then, utilize append create function. able do:

(define (sentence) (append (getnoun) '(and) (getnoun) (getverb)))

however, unable figure out way temporarily define variable. have far:

(define (sentence1) (append (getnoun) (lambda (verb getverb) (noun getnoun)) (verb) (noun) '(but) (noun) (verb) (noun)))

hints/help please?

you looking let.

http://docs.racket-lang.org/reference/let.html

here illustration usage:

(define (my-proc age) (let ([age-plus-10 (+ age 10)]) (printf "age ~a" age) (printf "age-plus-10 ~a" age-plus-10)))

notice how can temporarily define age-plus-10 , utilize later.

scheme

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -