Questions tagged [scheme]
Scheme is a functional programming language in the Lisp family, closely modeled on lambda calculus with eager (applicative order) evaluation. FOR questions about URL schemes PLEASE use the tag "URL-scheme".
scheme
8,160
questions
0
votes
0
answers
3
views
"Ill-formed syntax: (define (expmod a num num) ((exptmod num) a num))" in Scheme
I am learning SICP up to chapter 2.2.1 now. I have the following code:
(define (modular n op)
(lambda (a b)
(modulo (op a b) n)))
(define (exptmod p)
(let ((mod* (modular p *)))
(define (...
0
votes
1
answer
25
views
How to make `set!` change the variable in `let` (Scheme)?
Recently when I self-learnt MIT 6.5151 course, I have read SICP 1 to 2.1 as ps0 requires (also read 2.2.1 as CS 61A notes requires) and then Software Design for Flexibility (SDF) Prologue, chapter 1 ...
0
votes
1
answer
27
views
Does Guile Scheme have a document generator for docstrings or documenting comments?
The source code of Guile Scheme contains docstrings (e.g., https://git.savannah.gnu.org/cgit/guile.git/tree/module/srfi/srfi-43.scm#n107). In the source code of SLib I can event see comments with some ...
0
votes
1
answer
53
views
How to use symbolic expressions produced by a function to define another function?
I am trying to make a symbolic derivation function in Chez scheme. It works alright-ish (simplification is not yet being done):
(define (derive var expr)
;; var is the direction in which you would ...
0
votes
1
answer
58
views
Why does Scheme use the procedural representation of pairs?
I am reading SICP. It says in 2.1.3:
That is, the operations satisfy the condition that, for any objects x and y, if z is (cons x y) then (car z) is x and (cdr z) is y. ... Here are the definitions:
...
0
votes
1
answer
74
views
(Scheme) Having trouble with binary search tree in-order traversal
I'm trying to write a Scheme program that performs an in-order traversal of a binary search tree:
(define (inorder lst)
(cond
((null? lst)
'())
((not (pair? lst))
(list lst))
...
0
votes
2
answers
70
views
Store external data in guile modules?
Suppose I have a collection of external data structures in a txt file.
Whenever I need the data for computation I have to parse the file and then use it's values.
How to make it more convenient?
Keep ...
1
vote
1
answer
111
views
`1.0+1e-100=1.` in MIT-scheme
I am reading SICP and read this recitation about chapter 1. I use MIT/GNU Scheme as MIT course 6.5151 (6.905) does with version 12.1.
I am stuck at Problem 3.
Write a procedure that computes e.
I ...
0
votes
1
answer
56
views
Confused about how eof-object? works when applying read-line to input data from (current-input-port) in (MIT) scheme
I'm using the MacOS port of MIT Scheme 12.1. I was trying to generalize a code pattern (I've used a lot) that reads a text file's contents to read instead from the standard in.
I think there's ...
0
votes
2
answers
54
views
Why is (atom? (car '('bacon 'and 'eggs))) different from (atom? 'bacon) in ChezScheme?
I'm going through The Little Schemer in ChezScheme and in chapter 2 I run through the following problem. I write the definition of lat? according to the book.
(define lat?
(lambda (l)
(...
1
vote
1
answer
63
views
Understanding *abort continuations in scheme/racket
Days ago i started reading about continuations and delimited continuation control operators in Scheme (i'm working in racket but using scheme continuations). In that context i was trying the shift/...
0
votes
0
answers
54
views
Is there some error-case in this answer? for SICP 1.7
I'm a beginner with SICP.
For SICP 1.7, I assume this solution has some problem when '(improve guess x)' keeps returning different values compared to 'guess'.
But I can't find an error case for this ...
0
votes
2
answers
75
views
Why in SICP one can see seemingly useless evaluation of local variable expressions? Different Scheme implementations behave differently
The deposit and withdraw procedures in the make-account code from SICP both have seemingly useless balance variable expression to evaluate,
What is the practical purpose for doing that? (To me it ...
0
votes
0
answers
40
views
Why does Racket output 1 for (and 0 1)? [duplicate]
As the title asks, why does Racket output a 1 for a logical and between 0 1? The interesting this here is that the same operation but flipped positions of 0 and 1 give the proper output of 0. I'm no ...
0
votes
0
answers
32
views
How to fix "caddr: expects argument of type <caddrable value>" error in Scheme when parsing custom grammar?
I'm developing a Scheme program where I aim to parse a custom language using the sllgen library, focusing on handling try-catch-finally blocks. However, I'm encountering an error related to list ...