The mutator form in Racket is *set! *as in

(define (smaller)
  (set! *big* (- (guess-my-number) 1)))

Also you may find it helpful to learn from Realm of Racket
<http://realmofracket.com/> rather than Land of Lisp.

Dan



On Sat, Sep 17, 2016 at 10:22 PM, Angus <anguscom...@gmail.com> wrote:

> I am reading Chapter 2 Creating your first lisp program in the Land of
> Lisp book and attempting to use the code in Racket.  The syntax is slightly
> different and the smaller function is defined in Land of Lisp as:
>
> (defun smaller ()
>   (setf *big* (1- (guess-my-number)))
>
> where *big* is a global variable.
>
> In Racket I defined the other vars/functions like this:
> (define *small* 1)
> (define *big* 100)
> (define (guess-my-number)
>   (arithmetic-shift (+ *small* *big*) -1))
>
>
> My attempts at defining smaller in Rachet (which didn't work):
>
> (define (smaller)
>   (define *big* (- (guess-my-number) 1)))
>
> (define (smaller)
>   (set *big* (- (guess-my-number) 1)))
>
> How can I translate this function into Rachet syntax?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Daniel Prager*
Agile/Lean Coaching, Innovation, and Leadership
Profile: skillfire.co/dan
Startups: youpatch.com <http://www.youpatch.com>, skillfire.co
Twitter: @agilejitsu <https://twitter.com/agilejitsu>
Blog: agile-jitsu.blogspot.com
Linkedin: au.linkedin.com/in/danielaprager

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to