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

what is the alternative for internal definition

version of racket/drSCHEME i use does not allow me to use internal definitions using (R5RS) language like these two for examples below give me error messages define: not allowed in an expression context in: (define inp (read-command)) (define…
0
votes
2 answers

Recursive method in Scheme

I have a (in theory) simple method in Scheme, that has to use recursion. The problem is that I can't seem to figure out the recursion part... I have a procedure that takes a 'pointer' and arbitrary many arguments, and I need to pass the arguments…
user16655
  • 1,901
  • 6
  • 36
  • 60
0
votes
2 answers

Add or remove element in the middle of list (Scheme)

Is it possible to add or remove elements in the middle of a linked list in Scheme? I can't seem to think of a way doing this with car/cdr/cons, but I reccon there must be a way to this. If I have a list '(1 3 5 6), and I need to put in 4 between 5…
user16655
  • 1,901
  • 6
  • 36
  • 60
0
votes
1 answer

Append list from assoc to another list in Scheme

I'm a bit confused on how to append a list that I've gotten from the assoc procedure into another list, here is what I have: (define new-list (list 'test)) (define source-a (list '(a foo) '(b bar) '(c hello))) (append new-list (assoc 'a…
MannfromReno
  • 1,276
  • 1
  • 14
  • 32
0
votes
1 answer

What extension allows access to time function in r5rs?

A 4-year-old old post suggests that one might be able access the current-seconds and related functions in the r5rs language. Here's why I ask: I'm a high school teacher new to Racket and we are using the r5rs language. I would like to introduce…
0
votes
1 answer

In Scheme, Is there a filter like function defined in the R5RS specification?

My baseline for this questions comes from MIT's Structure and Interpretation of Computer Programs. In the book, a filter function is defined. I know that map is part of the spec, but I see nothing resembling filter. EDIT: Specifically I'm referring…
stantona
  • 3,260
  • 2
  • 24
  • 28
0
votes
0 answers

How to keep track of current position in a list while doing deep recursion

what I'm trying to do is take a symbolic expression, and replace all of its 'leaves' with the numbers in a list from left to right, so the left-most leaf should be replaced with 1, the next 2, etc, etc. This is the code I have currently (I'm using…
IBOED2
  • 151
  • 1
  • 2
  • 8
0
votes
1 answer

Schema Count number of element in the list

I know we have a function to count number of items in a list, however in this procedure I am can not use this function. So how can I count number of elements in a list. (define (last_element l count ) (+ count 2) (if (null? cdr l) …
Anup Singh
  • 313
  • 1
  • 5
  • 18
0
votes
1 answer

When would a cons return a cascaded list?

I was doing exercise 2.18 of SICP(Structure and Interpretation of Computer Programs, 2nd edition) to make a program to reverse a list. And here is my code: (define (rev l) (if (null? (cdr l)) l (cons (rev (cdr l)) (car l)))) When I…
Mr.Zhou
  • 143
  • 1
  • 8
0
votes
1 answer

Concise scheme R5RS define struct or class with multiple fields

I've managed to define a struct with one field, how to define multiple fields in one struct or class? I'm new to R5RS, I can only come up with problematic code, please see it as pseudo code expressing what I'm trying to do. (define recipe (let…
user3352539
  • 79
  • 1
  • 1
  • 8
0
votes
2 answers

Scheme. Recursive equivalence checking in the list

I have a problem with the function that is to remove the first occurrence of the specified element from the list. And i cannot use equal. What i'm doing wrong? (define f (lambda (E X) (list? X) (check E X))) (define check (lambda (E…
no_name
  • 31
  • 1
  • 5
0
votes
1 answer

How to create a macro that generates another macro in SISC / Scheme?

In Guile or using SRFI-46 it is possible like shown in Specifying a Custom Ellipsis Identifier. But is it possible in SISC or "pure scheme" R5RS? I know it is possible without using ellipsis, but what if I need to use inner ellipsis like the example…
Felipe
  • 16,649
  • 11
  • 68
  • 92
0
votes
1 answer

Undefined ADT in r5rs

I'm writing an ADT in r5rs and I'm using DrRacket. I put #lang r5rs at the top of my file and chose Determine Language from Source from DrRacket, but it tells me my ADT is undefined. I'm using DrRacket version 6.0. It's the first time I've had this…
JNevens
  • 11,202
  • 9
  • 46
  • 72
0
votes
1 answer

Scheme - How do I get each list in a list that's not made up of more lists

(define (walk-list lst fun) ;;walk-list(list, fun) (if (not(null? lst)) ;;IF the list isn't NULL (begin (if (list? lst) ;;&& the list is actually a…
Philip Rego
  • 552
  • 4
  • 20
  • 35
0
votes
2 answers

How can I get a list up until the last occurrence of an element from a list?

I'm using scheme R5RS. Given a list with multiple entries, I would like to return that list up until the last occurrence of a given element. So for the following input: A list '("hi" "how" "are" "you") Keyword "you" I want the following output: A…
Kittenmittons
  • 400
  • 3
  • 14