racket

DrRacket, R5RS and the error procedure.

I love DrRacket IDE (formerly DrScheme) but currently i'm building a pet project where i would like to be independent from it, meaning i'm commited to use only R5RS standard procedures. The thing is, in DrRacket there's this procedure called "error" which i would like to continue using but i can't find it in the Standards. What i woul...

Scheme result of a function

Hello, I have met the following code in Scheme: (define x! (lambda(x) (if (= x 1) 1 (* x (x! (- x 1)))))) (define fact x!) (define x! (lambda (x) x)) (fact 5) Everything is clear for me until re-defining x! and seeing the result of the function (20). How can it be explained?.. Why is it 20 and not 5!= 120. Thanks in advance...

Clojure or Scheme bayesian classification libraries?

Any pointers to scheme/racket or clojure bayesian classification libraries? I need one for a toy/learning project that I'm going to do. ...

Mechanism of a function in Scheme

Hello! Here it is a strange function in Scheme: (define f (call/cc (lambda (x) x) ) ) (((f 'f) f) 1 ) When f is called in the command line, the result displayed is f . What is the explanation of this mechanism ?.. Thanks! ...

Scheme symbolic equivalence

Hi all. The platform i'm working with is DrScheme. I've seen that a pair (a b) [constructed by (cons a b)] is implemented within the language like a procedure that looks like this: (define (cons a b) (lambda(pick) (cond ((= pick 1) a) ((= pick 2) b)))) and the selectors: (define (car x) (x 1)) (define (cdr x) (x 2))...

String length in Scheme

Hi All, I am not able to understand the error with the code below which simply prints the length of the string: (define codeLen (read)) (display codeLen) (define code (read)) (display code) (string-length code) I am getting an error : string-length: expects argument of type <string>; given a regards, darkie ...

CAR and CDR of a list in Scheme

Hi all, I am confused as to how car and cdr work on lists. Here is an example of what I have tried: (define sample (read)) (display sample) (display (car sample)) (display (cdr sample)) (display (car (cadr sample))) (display (cdr (cdr sample))) On entering the value '(A B C D E F), here is what I get: '(a b c d e f) quote ((a b c d...

Adding an element to List in Scheme

Hi All, Below is my code which takes a car element of a list(carVal) and an list(initialized to empty) as parameters. I want to append the element to the list but the same is not working. (define populateValues (lambda (carVal currVal) (append currVal(list carVal )) (display currVal))) The display shows empty list all...

PLT[Racket/Scheme] Compound Interest + Accumulators -How to....

Hi (geek) folks, I'm fiddling another time with a (should be easy) task. compound interest... (formula is known) Scheme... (For one single years everything works flawlessy) Problem: Accumulator needed... My program has to be able to remember the result of the former calculation and put it as a blueprint for the next one following. He...

Recursion & lists in Scheme

I've been trying to learn some programming on my own by working through the textbook How to Design Programs for Scheme. I've gotten through everything until now. Here's the problem: 9.5.5 Develop the function convert. It consumes a list of digits and produces the corresponding number. The first digit is the least significant, ...

Achieving variables in the local syntax in the Scheme environment

How we can achieve variables that we defined in the (local ...) syntax in Scheme? For example in this code below, (define (erkan x) (local ((define y 10)) (* x y))) how can I directly get the value of y ? ...

(define (average ....)) in Lisp

I'm just playing around with scheme/lisp and was thinking about how I would right my own definition of average. I'm not sure how to do some things that I think are required though. define a procedure that takes an arbitrary number of arguments count those arguments pass the argument list to (+) to sum them together Does someone have...

What do I need to do to get paid to Scheme?

I'm a big fan of functional programming in general, Schemes in particular, and PLT-Racket ideally. I am wondering what concrete steps are likely to get me into a position where coding Scheme (or some functional language) is the bulk of the work. I'm actually quite interested in academia, but on the other hand, I don't feel like I neces...

Why does this work in DrRacket but not in Racket from the console

(define pick (lambda (num lat) (cond ((null? lat) (quote())) ((= (sub1 num) 0) (car lat)) (else (pick (sub1 num) (cdr lat)))))) (define brees (quote (a b c d e touchdown g h i))) (pick 6 brees) The language in DrRacket is set to Advanced Student. It also works fine in the IronScheme...

Missing method in mred:canvas%?

I used MrEd Designer to make a user interface for a Scheme program. It includes a mred:canvas% on which I'd like to plot points using draw-point. It's defined as: (define (naca-ui-init {...} #:airfoil-canvas-class (airfoil-canvas-class canvas%) {...}) and later: (set! airfoil-canvas (new ...

How is Racket different Than Scheme?

Racket is a descendant of Scheme. How is Racket different than R6RS? What did it add, or take away, or is just different? I'm understanding that Racket is more than a language, it's a platform for languages. But I'm referring to the main Racket dialect. ...

Finding a prime number in Scheme using natural recursion

I'm still plugging away at the exercises in How to Design Programs on my own, but have managed to get stuck again. This time it's question 11.4.7: Develop the function is-not-divisible-by<=i. It consumes a natural number [>=1], i, and a natural number m, with i < m. If m is not divisible by any number between 1 (exclusive) ...

Scheme: Data serializing, efficient [and functional]

I'm serializing data which may be an integer, an object (list) with other nested objects, and trying to make a choice as to what approach to be using. Of two, the first one is to create bytevectors recursively and copy them in the calling functions to a larger single bytevector; the second one is to use some kind of the stream I could wr...

How to print a string in backward, in scheme ?

Hi, I know if I write my scheme code in the following way and type in (word ‘(a b c)), it will out put the list in the same order. Could you please tell me if there was a way I can print it out in opposite order. Ex- (list ‘c ‘b ‘a). it needs to be the user's input I print out in opposite order. So, I can't call it (reverse '(a b c))....

Packaging system in Racket

I would like to use the R6RS library/module system as detailed in Dybvig's TSPL4 chapter 10 in Racket. I selected "Pretty Big" language in DrRacket. But when I do (import (list-tools setops) (more-setops) (rnrs)) on the top window and run, I get this error: "import: misuse of unit keyword in: (import (list-tools setops) (more-setops)...