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
3
votes
1 answer

Possible to get R5RS code to work with SchemeUnit?

In a class I am taking we are using the old R5RS standard of Scheme to solve SICP assignments. I like to do test first development, so I figured a unit testing framework would be nice, and I chose SchemeUnit for writing the small tests. This has…
oligofren
  • 20,744
  • 16
  • 93
  • 180
2
votes
1 answer

ANTLR: grammar for the R5RS lexical structure, problem with numbers

i'm implementing an IDE for scheme in eclipse using DLTK. So far, i am programming the grammar to recognize the lexical structure. i'm following the official EBNF which can be viewed here: http://rose-r5rs.googlecode.com/hg/doc/r5rs-grammar.html i…
zhujik
  • 6,514
  • 2
  • 36
  • 43
2
votes
0 answers

Unquote splice equivalent in Scheme Hygienic Macros

I have Scheme implementation and right now I'm testing Hygienic macros. I have macro --> that work like this: (--> document (querySelector "body")) that will just call JavaScript document.querySelector("body") and I want to create macro that will…
jcubic
  • 61,973
  • 54
  • 229
  • 402
2
votes
1 answer

Encoding Huffman Tree Scheme

I am trying to write a function, (codeWords t), which traverses a Huffman tree (adds #\0 when it goes left, adds #\1 when it goes right...) and returns these values in pairs of the symbol at a leaf along with its associated encoding as a string over…
2
votes
1 answer

R5RS - Display number from operation as decimal

I want to display a number as decimal, however it keeps showing as a fraction Example (/ 7 9) ; --> displays as 7/9 but should be .77777 I've tried the builtin #d but it doesn't seem to work on operation results, also number->real and other…
Alter
  • 3,332
  • 4
  • 31
  • 56
2
votes
1 answer

"Thread-first" macro and "thread-last" macro from Clojure implemented on Scheme?

I'm trying to implement the macros -> and ->> in Scheme and my final result was: ;; ;; See https://clojuredocs.org/clojure.core/-%3E ;; for more info. ;; (define-syntax -> (syntax-rules () ((_ a) a) ((_ a (b c ...)) (b a c…
Felipe
  • 16,649
  • 11
  • 68
  • 92
2
votes
2 answers

Why is this if statement like this?

The question is to write a function that takes a list and partitions it into two equal-sized in one list, and returns a list whose first element is the first list and whose second element is the second list. I have a code that does that, but there…
Vivian
  • 31
  • 1
2
votes
2 answers

Confused with behavior of this procedure

(CONTEXT) I've defined a procedure that applies another one-argument procedure object to it's parameter twice. Take for example the procedure inc that adds 1 to it's argument, (double inc) will add two. hence ((double inc) 5) returns 7. (THE…
TomatoFarmer
  • 463
  • 3
  • 13
2
votes
1 answer

Scheme - standard way in R5RS to execute an external command?

Is there a way in Scheme Revision 5 to call out to an external program? For example: (system "ls") If not, is there any "official" way to do this, such as specified in a SRFI or a later revision of the Scheme spec (R6RS, etc)?
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
2
votes
2 answers

Scheme - "inexact" concept in R5RS numerical tower

While thinking about the way to implement Scheme R5RS, I have become puzzled about the following extract of R5RS (pages 22-23): (remainder -13 -4) ==> -1 (remainder -13 -4.0) ==> -1.0 ; inexact (lcm 32 -36) ==> 288 (lcm 32.0 -36) ==> 288.0 ;…
Nicolas_75
  • 95
  • 6
2
votes
2 answers

How to make tribonacci function tail recursive?

I am making a tribonacci function that, given n, returns the value, with n(0)=0,n(1)=0,n(2)=1. My current code is just normal recursion, but how can i make it tail recursive? (define (tribonacci n) (if ( < n 0) #f (cond ((= n 0) 0) ((=…
Slava A.
  • 97
  • 6
2
votes
1 answer

How To Mutate Variables Scheme

I'm trying to sum a list using mutable objects for an assignment.letis used here to allow me to mutate x the total sum and counter. I'm not very well versed with scheme hence the use if statements for each number in the list lst: (define lst (list 1…
Artemis
  • 139
  • 12
2
votes
1 answer

List all leaves of Huffman tree

This is my Huffman coding that returns an empty list. My purpose was to make it add all the pairs to listenr1 but it seams to only return an empty list. I'm not sure why it's not appending, but I think I have misunderstood a fundamental part of…
2
votes
2 answers

Different treatment of parameters: lambdas vs. defines in Scheme

I have two constructs that I expected to be functionally the same, but they are not and I can't figure out why. Using define (define (x2 . b) (display b) (newline)) (x2 3 4 5) => (3 4 5) Using lambda ((lambda (. b) (display b) …
AndrewE
  • 353
  • 1
  • 4
  • 16
2
votes
1 answer

Number Partitioning in R5RS

I was asked in an internship interview to do a R5RS program that creates a function, let's say two-subsets. This function has to return #t if the list L contains two subsets with equal sums of elements and with equal numbers of elements, otherwise…
Benz
  • 289
  • 4
  • 15
1 2
3
14 15