[racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-12 Thread Angus
[#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 subs

Re: [racket-users] difference between function returning a string and function returning a symbol

2016-09-24 Thread Angus
ure 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

[racket-users] difference between function returning a string and function returning a symbol

2016-09-24 Thread Angus
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

[racket-users] Assigning a new value to a global variable in Rachet - how?

2016-09-17 Thread Angus
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

[racket-users] Realm of Racket chapter 5 easy question variable update question

2016-10-01 Thread Angus
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

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
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) > >

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
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) > >

Re: [racket-users] Contract violation where number expected - can't understand why

2016-10-01 Thread Angus
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?,

[racket-users] How to apply side effects to all elements in a list

2017-03-22 Thread Angus
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)

[racket-users] How to check if a value is not false

2017-04-15 Thread Angus
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))) <>]

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Angus Comber
sen <matth...@ccs.neu.edu> wrote: > > > On Feb 12, 2017, at 3:00 PM, Angus <anguscom...@gmail.com> 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 large

Re: [racket-users] Why doesn't this maxval function correctly return the maximum value in the list

2017-02-13 Thread Angus Comber
ust lift aux out. > > > > On Feb 13, 2017, at 3:18 PM, Angus Comber <anguscom...@gmail.com> wrote: > > > > If I change the code to: > > > > (define (maxval lst) > >(define (aux lst max) > > (cond [(null? lst) max] > >[(