5
votes
3answers
195 views

Not return anything from LISP/Scheme

Basically, I would like to use map to do selection in a list like (define tbl '(a b c d)) (map (lambda (item 'c) (if (eq? item 'c) item (...what in else?) ))) The result I want is '(c) I tried ...
4
votes
1answer
98 views

Is this simiple purely functional queue valid?

I have developed a purely functional queue in Lisp (Scheme) as follows: ;Internal functions (define (delay-cons x s) (cons x (lambda () s))) (define (delay-car s) (car s)) (define (delay-cdr s) ...
3
votes
2answers
120 views

Tail call optimization racket

I'm trying to learn some functional programming and am doing project euler problems in scheme (racket) to get me started. I'm currently on problem 15 and I think I have a correct function for ...
4
votes
1answer
84 views

Ignoring multiple return values in Racket

In Racket, it's possible to return multiple values from a function by doing e.g. (define (foo) (values 1 2 3)) Then we can bind them by doing (define-values (one two three) (foo)) Now one is ...
1
vote
1answer
55 views

Scheme Parameter Not Applicable

I am starting to learn Scheme and well, I am trying to implement my own max function that gives the max of just two parameters. I've written the function like this: (define (myMax x y) (cond ((> x ...
1
vote
3answers
48 views

Custom function for length of a list in Scheme?

My lecturer has provided the following code: (define (length list) (cond (( null ? list) 0 ) (( atom ? list) 1 ) ( else ( + 1 ( length (cdr list)))) However it wouldn't compile and Scheme kept ...
0
votes
2answers
60 views

Passing multiple variables (image->color-list) as a procedure argument RACKET

I am trying to create a procedure which will accept two colour-lists. Because this procedure is within another procedures(local). I need to convert image->color-list as I am passing the arguments. I ...
3
votes
2answers
67 views

How to express let* as a lambda expression (not the regular let)

I have a scheme related question, how can we implement let* as a lambda expression. To be more precise, I am not wondering about the "regular" let, but the let with * which lets us use one let ...
-1
votes
2answers
89 views

SICP example doesn't work on Racket

I am trying an example on Chapter 4 of SICP (part of writing the LISP interpreter) (define (definition-value exp) (if (symbol? (cadr exp)) (caddr exp) (make-lambda ...
0
votes
0answers
76 views

make-lambda function alternative in racket

I am learning scheme by reading SICP. One function in SICP measured is (make-lambda ...) I am using Racket as the scheme interpreter. However Racket doesn't have make-lambda function built in. ...
1
vote
0answers
183 views

Can every recursive function be rewritten using tail calls? [duplicate]

Can every recursive function be rewritten using tail calls? If not, what are examples of recursive functions for which this can't be done?
2
votes
2answers
68 views

scheme pattern checking if it is a number

I am a scheme beginner and I am wondering how to explain this piece of scheme code? Looks so preculiar! (define (calc2 exp) (match exp [(? number? x) x])) ...
3
votes
1answer
140 views

Can I use Gambit-C, Mlton, or Chicken Scheme with Google's Native Client

Those functional language compilers can each compile a functional language to C code. Google's NaCl SDK can compile C. Is it reasonable to create Native Client applications by compiling first with ...
1
vote
4answers
72 views

How to write the following function in scheme

I am new to scheme and doing some exercises. I am trying to do the following: The function i am going to write takes one list parameter (no input check needed). Then it remoces multiple occurences of ...
1
vote
2answers
58 views

How to decide the parantheses in scheme

I am a little bit confused about putting the parantheses in scheme. The following example: =>(define foo1 (lambda (n) (+ n 1))) =>(foo1 ((lambda () 5))) =>value:6 Gives the result 6. But ...

1 2 3 4 5 15
15 30 50 per page