I have a function that can return either false or a node. I have to check four
permutations:
both nodes false,
left node false,
right node valid, left node false
both node valid
I am doing it using cond like this:
(define (lines t)
(cond [(and (false? (node-l t)) (false? (node-r t))) <>] ;
I am a bit stuck on rendering images in a list.
Here is my code below.
(require 2htdp/image)
(define-struct bear-state (x y rotation size))
(define MTS (empty-scene WIDTH HEIGHT))
BEAR-IMAGE is just a graphic - of a bear.
(define (render-bear b)
(place-image (scale (bear-state-size b) (rota
gt; > On Feb 13, 2017, at 3:18 PM, Angus Comber wrote:
> >
> > If I change the code to:
> >
> > (define (maxval lst)
> >(define (aux lst max)
> > (cond [(null? lst) max]
> >[(> (car lst) max) (aux (cdr lst) (car lst))]
> >
sen
wrote:
>
> > On Feb 12, 2017, at 3:00 PM, Angus wrote:
> >
> > I am a beginner Racket developer by the way.
> >
> > Here is my maxval function which is supposed to take a list and return
> the largest integer in the list.
> >
> > (define (ma
[#t (aux (cdr lst) max)]))
(aux lst 0))
Using the function always returns the last value in the list
> (maxval (list 1 2 3 5 6 1))
1
The code looks correct to me, but I must be missing something. What have I
done wrong?
Angus
--
You received this message because you are subscribed
On Saturday, 1 October 2016 16:13:01 UTC+1, Ben Greenman wrote:
> Maybe this will help:
>
>
>
>
> (struct interval (small big guesses))
>
> creates 5 new functions
> interval, for making intervals. For example (interval 5 10 0) creates an
> interval from 5 to 10 that has 0 guessesinterval?,
On Saturday, 1 October 2016 15:30:19 UTC+1, Vincent St-Amour wrote:
> On Sat, 01 Oct 2016 09:13:25 -0500,
> Angus wrote:
> > Then I changed smaller (and bigger) like this:
> >
> > (define (smaller w)
> > (interval (interval-small w)
> >
On Saturday, 1 October 2016 15:30:19 UTC+1, Vincent St-Amour wrote:
> On Sat, 01 Oct 2016 09:13:25 -0500,
> Angus wrote:
> > Then I changed smaller (and bigger) like this:
> >
> > (define (smaller w)
> > (interval (interval-small w)
> >
I am now attempting to do the following ch5 question in Realm of Racket:
Change the Guess My Number game so that it displays the number of guesses the
program takes to find the players number. Hint: you might need to change the
data used to represent the data used to represent the world's state
I am working through Realm of Racket chapter 5, last exercise was: Find an
image of a locomotive and create an animation which wraps around to the left
side of the screen after passing the right margin.
I have a solution which is below, but have some questions:
1. Is the solution below a reason
of playing with symbols. (It is an expression not a
> function.)
>
>
> > On Sep 24, 2016, at 11:45 AM, Angus wrote:
> >
> > I am reading through Realm of Racket and saw this function in the
> > conditions chapter:
> >
> > (if (= (+ 1 2) 3)
> &g
I am reading through Realm of Racket and saw this function in the conditions
chapter:
(if (= (+ 1 2) 3)
'yup
'nope)
So this function returns a symbol. Will be 'yup in above case. But 'yup
confuses me. I don't really understand why you would want to return 'yup.
For example, I co
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 va
13 matches
Mail list logo