Questions tagged [r5rs]

The 5th Revised Report on the Algorithmic Language Scheme

The 5th Revised Report on the Algorithmic Language Scheme, R5RS is a de facto standard for Scheme implementations. Schemers take pride in the fact that at 50 pages the specification is shorter than the index for books on some other languages.

225 questions
0
votes
1 answer

What is happening in each line of this code?

I know the overall code is to return the last nth elements of the list, however, I don't understand the process, like in each line what is happening(and why, if possible)? (define (last-n lst n) (define (help-func lst drop) (cond ((>…
seaweed
  • 21
  • 2
0
votes
2 answers

How to have an increasing variable correctly here?

(define (teken-n x y n) (if (not (zero? n)) (begin (teken-symbolen x y) (teken-n x y (- n 1))))) (define (teken-symbolen-combinatie x y n) (if (not (zero? n)) (begin (let ((acc 0)) (teken-n x y (+…
TomatoFarmer
  • 463
  • 3
  • 13
0
votes
2 answers

Create a partition of list into three parts in scheme

I am trying to find a way to split a list up into three parts. I have used a helper function and the parameters should be as follows: It evaluates to a list of three lists, containing 1) the items in the list less than pivot, 2) the items in the…
user8928280
0
votes
2 answers

Contract Violation

I am trying to write a recursive function to test if the digits in the integer entered are in ascending order. When I run my code I get a contract violation error. (define (rising-numbers n) (if(zero? (truncate n)) (modulo n 10) (>…
Seol
  • 49
  • 2
0
votes
1 answer

Scheme Lisp Continued Fraction for Square Roots

I need to create a continued fraction function to find the square root of a number and use it in a square root function. the series I am using and the rearranged version for code is shown above. (define (contfrac x) (cond ((= x 0) 1) …
user8928280
0
votes
2 answers

Scheme Lisp program for the sum of n even numbers

I need to make a function that computes the sum of the first n even numbers starting with 0 (i.e (even-sum 4) would return 12). (define (even-sum n) (cond ((= n 0) 0) ((= n 1) 0) (else (+ (* n 2) (even-sum (- n 2…
user8928280
0
votes
2 answers

Procedure works only if defined twice

I have defined a map procedure and a square procedure. The square procedure works fine, but the map one only works if it is defined twice. Given the following code: ; Squares a number. (define square (lambda (n) (* n n) )) ; Applies function f…
Jeroen
  • 15,257
  • 12
  • 59
  • 102
0
votes
1 answer

printing in a recursive procedure

I have a stack procedure which is designed in a object oriented programming paradigm, one of the nested procedures in my stack is a print. Since my stack is literally a list I can easily print it by just calling the global variable my-stack but I…
user8866063
0
votes
1 answer

r5rs: Not a procedure errors

Here is the code I came out (to display all pairs of balanced parentheses with length n) (define (combine-list l r) (append l (cons r '()))) ;(combine-list '(1 2 3) '(4 4)) (define(bps n) (bps-iter '() (/ n 2) 0 0)) (define (bps-iter lst n…
0
votes
1 answer

How to delay an image swap in DrRacket?

i am trying to make aan animation for my game in DrRacket, when i press the left button i want my image to do a running animation (legs open --> legs closed). Is there a way i can delay the image swap? The computer does the swap soo fast that you…
KillerZ224
  • 41
  • 2
0
votes
1 answer

trying to implement my own stack object in DrRacket

Here is what I have so far, but I am unable to run it since there is an error so I don't know if it works, I am trying to create my own stack object using Object Oriented programming in DrRacket, I am using a dispatch method to call the different…
user8866063
0
votes
1 answer

Racket variable memory

Given this code: (define (wrapper n) (define (sum-ints) (set! n (+ n 1)) (display n)(newline) (if (= n 3) n (+ n (sum-ints)))) (sum-ints)) Calling this procedure with n = 0 (wrapper 0) => 1 2 3 6 I had…
user8866063
0
votes
2 answers

adding element to a list

I am trying to implement a procedure in Scheme that will add an element x at position i to an existing list. This is what I came up with: (define empty-list '()) (define (add i x L) (cond ((null? L) (set! L (list x))) ((= i 0)(set! L (cons…
user53073
  • 51
  • 7
0
votes
1 answer

finding the depth of a list in racket

I am trying to make a procedure that tells me the depth of a list. This is what I have so far: (define (depth lst) (let recurse ((lst lst) (n 1)) (cond ((null? lst) '()) ((not (pair? (car lst))) (cons n (recurse (cdr lst)…
user8866063
0
votes
1 answer

Removing n number of elements from a list in racket

I am trying to create a procedure to delete n number of elements from a list starting at an index i, so far this is what I got: (define (remove L i n) (cond ((null? L) '()) ((and (= i 0) (= n 0)) L) (else (cons (car L)…
user8866063