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
2
votes
3 answers

Scheme number to list

I need a subroutine for my program written in scheme that takes an integer, say 34109, and puts it into a list with elements 3, 4, 1, 0, 9. The integer can be any length. Does anyone have a trick for this? I've thought about using modulo for…
Matt
  • 5,408
  • 14
  • 52
  • 79
2
votes
1 answer

Scheme Binary Search Tree Error (R5RS)

I am completely new to Scheme and functional languages in general. I am trying to create a binary search tree. The format of a node is a list of three elements, the first being the value at the node, the second being the left child node, and the…
Ryan C. Stacy
  • 87
  • 1
  • 7
1
vote
2 answers

reading file : bad syntax (multiple expressions after identifier)

(define bootstrap-c-code (define (from-file file-name) (let* ((ip (open-input-file file-name)) (res (read-text-file-from-input-port ip))) (close-input-port ip) res)) (from-file "llvm.c")) Error : define:…
cnd
  • 32,616
  • 62
  • 183
  • 313
1
vote
0 answers

How to "load" a file only once in scheme r5rs?

Is there a way to make sure that a scheme file (R5RS) is loaded only once? That is, if foo.scm is loaded multiple times in bar.scm (directly or indirectly), make sure the content of foo.scm is only loaded the first time. In C++, one can enclose the…
thor
  • 21,418
  • 31
  • 87
  • 173
1
vote
0 answers

Defining a "purely functional" R5RS env

To the Racket specialists, if I run this code, can I assure that everything next will be deterministic and purely functional? Or am I missing something? #lang r5rs (define-syntax unsafe (syntax-rules () ((_ fn ...) (begin …
Felipe
  • 16,649
  • 11
  • 68
  • 92
1
vote
1 answer

How would I Implement a repeat function that would make a stream full of a repeating int?

The questions is: Write a function (repeat x) which, given a value x, produces a stream that repeats x ad infinitum. For instance, the call (take (repeat 42) 5) produces (42 42 42 42 42). My problem is that my repeat function doesn't know what to…
Moronis2234
  • 57
  • 1
  • 6
1
vote
2 answers

Scheme: the procedure is recursive, but is the process recursive or iterative?

so I'm not sure if I finally understood it or maybe I'm still wrong. Is it correct that: (define (add-one x) (+ x 1)) (define (sub-one x) (- x 1)) (define (add-numbers x y) (if (zero? y) x (add-numbers (add-one x)…
Veronica
  • 69
  • 1
1
vote
1 answer

ANTLR resolving non-LL(*) problems and syntactic predicates

consider following rules in the parser: expression : IDENTIFIER | (...) | procedure_call // e.g. (foo 1 2 3) | macro_use // e.g. (xyz (some datum)) ; procedure_call : '(' expression expression* ')' …
zhujik
  • 6,514
  • 2
  • 36
  • 43
1
vote
1 answer

An ANTLR grammar for Scheme's quasiquotations

Considering following grammar in EBNF: http://pauillac.inria.fr/cdrom_a_graver/www/bigloo/manual/r5rs-8.html The quasiquotations grammar given there is not context free: --> -->…
zhujik
  • 6,514
  • 2
  • 36
  • 43
1
vote
1 answer

Combine Two Heaps Given a First Order Relation

What I have to do: Define a SCHEME procedure, named (combine f Ha Hb), which accepts three arguments, f, a firstorder relation which is used to order the elements in the heap, and two heap structures, Ha and Hb, which have been constructed using the…
1
vote
1 answer

How can I get my code to return the value?

"Use your partial sum function and the sequence in 3a to produce a stream containing successive approximations to sin(x)" I'm assuming the question is for me to have the value return, however, the output is "#< stream >" instead. What is wrong with…
seaweed
  • 21
  • 2
1
vote
2 answers

the sum of the all integers from a to b, What's Wrong With My Code?

The goal is to create a code that will compute the sum of all integers from a to b and if a > b then it should evaluate to 0. (define (sum-from-to a b) (if (> a b) 0 (+ a (sum-from-to (- a 1) b)))) My problem is that when I run this,…
seaweed
  • 21
  • 2
1
vote
2 answers

Can't get the end list i want in swapping procedure

Ultimately, i shall be trying to reimplement sorting algorithms in scheme for linked lists. I have written a subprocedure that will help me along the way. The goal is to simply swap 2 elements, given as arguments "pair1 and pair2" and then return…
TomatoFarmer
  • 463
  • 3
  • 13
1
vote
1 answer

Need explanation on reverse scientific notation function in Lisp

Here's the function i have and understand to go from 1) your coefficient and 2) your exponent to then extract the number out of the scientific notation. Example: coefficient 7, exponent 3 7 * 10^3 = 7000 (define (scientific coeffiecent…
TomatoFarmer
  • 463
  • 3
  • 13
1
vote
1 answer

Scheme groupSum Function

I'm trying to write a Scheme function that takes two parameters, a list of numbers and another number, and returns true if a subset of the list adds up to that number. Example Output: > (groupSum '(1 2 5) 7) > #t > (groupSum '(1 2 5) 4) > f So far,…
Bryce S
  • 59
  • 1
  • 1
  • 9