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

Sorting list of lists by their first element in scheme

I'm working on sorting a list of lists by their first element for example (sort (list '(2 1 6 7) '(4 3 1 2 4 5) '(1 1)))) expected output => ('(1 1) '(2 1 6 7) '(4 3 1 2 4 5)) The algorithm I used is bubble sort. And I modified it to deal with…
zach chen
  • 119
  • 1
  • 10
2
votes
1 answer

sorting strings in lexicographical order in scheme

I'm new to scheme. I'm wondering how to sort strings in lexicographical order in scheme. For example: (sort (list "cat" "apple" "dog")) (apple cat dog) In C++, I can have 'A'<'B', but it seems not work in scheme. I have referred online, but most…
zach chen
  • 119
  • 1
  • 10
2
votes
1 answer

Function evaluating to lambda cannot be used to define new function within scope

In scheme you can define functions which return a lambda expression and use them to define new functions. For example, you can write this code (define (pow-iter base exp r) (if (= exp 1) r (pow-iter base (- exp 1) (* base…
user2897701
2
votes
1 answer

How to iterate through every element in list without removing elements in scheme

My problem is to make a simple plus-minus program using Racket R5RS language. The basic idea of the problem is to put plus/minus signs in front of every element in list and check if the result is one of the elements in list. Below is what I have…
S.Y
  • 35
  • 5
2
votes
1 answer

R5RS Scheme input-output: How to write/append text to an output file?

What is a simple way to output text to file in a R5RS compliant version of Scheme? I use MIT's MEEP (which uses Scheme for scripting) and I want to output text to file. I have found the following other answers on Stackoverflow: File I/O operations -…
ansebbian0
  • 201
  • 2
  • 9
2
votes
1 answer

Writing a While Loop in Scheme

I am trying to implement a while loop using recursion with lambda, but I just don't understand how to do it. I am supposed to start with this lambda expression: ((lambda (x) (x x)) (lambda (x) (x x)) My first question is why does this cause…
user16655
  • 1,901
  • 6
  • 36
  • 60
2
votes
1 answer

Remove duplicates in streams (Scheme)

I'm trying to remove duplicates in my streams in scheme R5RS. Here's my code. (define (remove-duplicates lst) (cond ((stream-null?? lst) stream-null?) ((not (memq (stream-car lst) (stream-cdr lst))) (cons-stream (stream-car lst)…
2
votes
1 answer

R5RS "provide" issues

I made a program in Racket and now I have to change my code to R5RS. But I immediately get errors. I had the following code in Racket : #lang racket (provide a-function) (define (a-function) ; Do something #t) (define a-variable #t) Then I…
Kevin
  • 2,813
  • 3
  • 20
  • 30
2
votes
2 answers

How to 'display' multiple parameters in R5RS Scheme

In R5RS Scheme how do you display multiple parameters, with a single call? my implementation below works, but adds extra parentheses and spaces. #!/usr/bin/env racket #lang r5rs (define (display-all . rest) (display rest)) (display-all "I " "have "…
GlassGhost
  • 16,906
  • 5
  • 32
  • 45
2
votes
1 answer

ANTLR grammar for scheme R5RS

I'm beginner in ANTLR and I'm learning it by an example. I use C as my target language. The example is a Scheme R5RS grammar file taken from this question, with a little modification(rename the grammar name and add some options with the grammar…
pysuxing
  • 161
  • 7
2
votes
1 answer

Scheme - Removing Sublists from Lists of Lists

I've a list of lists, eg. ((x y z) (y z) (x y)), and I was wondering if in R5RS Scheme there might be a way to remove only the sublists from this list: eg. (y z) is a sublist as it is already 'inside' (x y z)), which in our example would leave ((x y…
2
votes
2 answers

How to use an image in R5RS

I'm looking for a way to import a .jpg file into R5RS. I would like to use it as background for a game that I'm making. Thanks!
JNevens
  • 11,202
  • 9
  • 46
  • 72
2
votes
2 answers

scheme call/cc for handling errors

I have a Scheme application that accepts some user input, computes, and gives some output. I would like to make it more robust by enabling some kind of error handling and a way to exit smoothly. Call with current continuation seems to be the thing…
Matt
  • 5,408
  • 14
  • 52
  • 79
2
votes
2 answers

add1 function from scheme to R5RS

I've written some code but it's not working because the add1 function I used in Scheme is not working with R5RS. What can replace add1 in R5RS?
2
votes
1 answer

Scheme list always in reverse order

Probably a trivial question for most of the more advanced schemers here, but as a newcomer, I've found this to be a problem. I need a way to construct a new list that is in the same order it was when it came in. As an example, say we are given a…
Matt
  • 5,408
  • 14
  • 52
  • 79