Skip to main content
Filter by
Sorted by
Tagged with
0 votes
3 answers
93 views

I am trying to learn Lisp, but it seems like I can not quite get behind how the quotes and the evaluation works. Why does the following expression ((car '(car)) '(a b)) not evaluate to a in the REPL? ...
Nico's user avatar
  • 111
1 vote
2 answers
155 views

Here is the question from Mitchell Wand's Essentials of Programming Language: Exercise 1.19 [⋆ ⋆] (list-set lst n x) returns a list like lst, except that the n-th element, using zero-based indexing, ...
YCH817's user avatar
  • 123
2 votes
0 answers
53 views

I am implementing circular evaluator in Chapter 4 SICP with racket, it seems that the code running fine only it cannot add new frames to the environment due to set-car! issue. I tried the followings: ...
QianruZhou's user avatar
1 vote
1 answer
80 views

I wonder whether it is possible to call define-syntax-rule in a loop-like construction like for-each. I explicitly say 'loop-like' because I know that normal Scheme evaluation comes after macro ...
lemzwerg's user avatar
  • 852
1 vote
1 answer
113 views

I'm playing around with implementing looping using call/cc and wrote a map function like this: (define (map1 f l) ((lambda (state) (let ((cc (car state)) (l (cadr state)) (...
NateT's user avatar
  • 312
1 vote
1 answer
63 views

In the documentation for the array_copy function in Guile Scheme is a warning that in the copy, "the array increments may not be the same as those of src". (Where "src" is the ...
neniu's user avatar
  • 431
4 votes
2 answers
84 views

I have an undirected graph which nodes are numbered from 0 to 5. Adjacencies are given with a vector of lists #((1 2) (0 3) (0) (1) (5) (4))), thus node 0 is connected to nodes 1 and 2, node 1 is ...
david's user avatar
  • 1,593
2 votes
1 answer
129 views

For this code (using Racket IDE) when doing "Run" #lang scheme (define (queue! q x) (let ( (b (list x)) ) (if (null? (car q)) (set-cdr! q b) (set-cdr! (car q) b)...
Scooter's user avatar
  • 7,111
1 vote
3 answers
91 views

Trying to build a very simple stack structure : (define (make-stack lst) (lambda message (case (car message) ((see) (newline) (write lst)) ((empty?) (null? lst)) ((push) (begin ...
david's user avatar
  • 1,593
1 vote
0 answers
59 views

I'm trying to figure out how to implement dynamic-wind in the context of delimited continuations. Any resources or conceptual model? While I found reference implementations of dynamic-wind for the ...
Teng Man Leong's user avatar
1 vote
2 answers
94 views

I'm working with floating-point numbers in Bigloo Scheme, and I encountered a precision issue when performing a simple multiplication: (* 0.005 1e-9) ;; => 5.0000000000000005e-12 I was expecting ...
Gurpreet Singh's user avatar
-1 votes
1 answer
68 views

In Scheme (extempore version) I sometimes use expressions similar to the following to choose alternative defined callback nodes. (random (cons 0.1 'node1) (cons 0.2 'node2) (cons 0.7 'node3)) This ...
George J Wright's user avatar
1 vote
3 answers
138 views

I wrote a simple intersection function on two lists: (define (intersection l1 l2) (if (null? l1) '() (if (member (car l1) l2) (cons (car l1) (intersection (cdr l1) l2)) (...
david's user avatar
  • 1,593
0 votes
1 answer
49 views

I am reading minirop.pdf and it seems to be written in a dialect of MiniKanren that is outdated. I am interested in how I can port this style of MiniKanren to miniKanren-with-symbolic-constraints, ...
Janus Troelsen's user avatar
2 votes
1 answer
194 views

I just found about these two expressions in Scheme: (quotient (expt 1000 999) 998001) (floor (/ (expt 1000 999) 998001)) They return bigInt that looks like this 100200300 ... 999 (with all numbers ...
jcubic's user avatar
  • 67.1k
-1 votes
2 answers
191 views

I have a Scheme program that I want to port to OCaml, and it uses lots of set-car! and set-cdr! inside helper functions. For nested mutable lists, do I need to make their types like x ref list ref ...
Cs_J's user avatar
  • 141
1 vote
1 answer
131 views

I'm learning syntax-case macro system. This is what I have so far: (define-syntax loop (lambda (x) (syntax-case x () [(_ (var val x ...) body) (with-syntax ([recur (datum->syntax ...
jcubic's user avatar
  • 67.1k
0 votes
1 answer
89 views

I want to create a macro with fields defined as (<field-name> <field-getter> [ setter <field-setter> ] [ default <field-default> ]) (default is for future developments). To ...
ChillPC's user avatar
0 votes
1 answer
86 views

Here is the minimal example: 1 ]=> (if #f (quasiquote ((unquote if))) (quasiquote (if))) ;Classifier may not be used as an expression: #[classifier-item 12] 2 error> (quasiquote (if)) ;Value: (...
An5Drama's user avatar
  • 774
0 votes
1 answer
74 views

Can Scheme "splice" the result of values or a list as the arguments for a function call? For example (imagined syntax): (list 0 (values 1 2) (values 3 4) 5) would return (0 1 2 3 4 5). The ...
user11589013's user avatar
1 vote
1 answer
64 views

I encountered some errors with pattern matching. For quasi-quote, the "ooo" pattern including "..." does not work. I looked at source code "guile-3.0.10/module/ice-9/match....
jcnn's user avatar
  • 13
0 votes
0 answers
57 views

I am doing this question, and others, for HW but when I run my code it is giving me this error: enter image description here (define prefix? (lambda (xs ys) (if (null? xs) #t (if ...
Matthew Wetzler's user avatar
1 vote
1 answer
83 views

I try this LISP snippet from the Structure and Interpretation book (define (a-plus-abs-b a b) ((if (> b 0) + -) a b)) in emacs by C-x C-e, or by evaluating the whole buffer. either way and get ...
Stephen's user avatar
  • 622
0 votes
1 answer
56 views

Does a Lisp or Scheme cons bear any similarities or theoretical kinship to a dot product? In the Lisp family (cons 1 2) produces (1 . 2) which looks a lot like a dot product. Just coincidence?
147pm's user avatar
  • 2,289
2 votes
1 answer
132 views

This is one exercise from Software Design for Flexibility (SDF) book: Here is an example: ;;; A missing match! (unify:internal '(((?? x) 3) ((?? x))) '((4 (?? y)) (4 5)) ...
An5Drama's user avatar
  • 774
0 votes
3 answers
149 views

I can't seem to find a way or an api to download a file in guile, I'm a beginner so I don't know how to add libraries, I'm using the guix package manager. I manage to make some code like this. (use-...
Rainb's user avatar
  • 2,567
1 vote
1 answer
112 views

I have the following Scheme program: (define sg-pair (let () (define x #f) (cons (call/cc (lambda (c) (set! x c))) ...
Aly's user avatar
  • 872
1 vote
1 answer
116 views

I am trying to make a macro similar to register-groups-bind in the Common Lisp cl-ppcre library. The idea is that you make a regex with groups, and give it a list of variables, statements to execute. ...
Mark Wutka's user avatar
0 votes
2 answers
144 views

So in Lisp/Scheme, there are these 'symbols', which are basically, if I understand correctly, and correct me if I'm wrong, references to variables (not their values). I was wondering if there's a ...
JorensM's user avatar
  • 510
1 vote
1 answer
119 views

I'm trying to make a function in Scheme that asks the user for input to complete a continuation. As part of this, I want to print out the continuation so the user can see what will happen with their ...
Joseph Camacho's user avatar
1 vote
0 answers
64 views

This is from one footnote in SICP: Note that these lazy lists are even lazier than the streams of chapter 3: The car of the list, as well as the cdr, is delayed. ^[41] [41] This permits us to create ...
An5Drama's user avatar
  • 774
0 votes
0 answers
55 views

minimal working code demo: (define (demo-tree) (custom-cons 0 1)) (define-syntax custom-cons (syntax-rules () ( ; (_ x y) (custom-cons x y) (cons-stream x y) ))) (custom-...
An5Drama's user avatar
  • 774
0 votes
2 answers
64 views

In my Scheme interpreter written in JavaScript, I want to modify the some function that that checks if any of the elements in the list return true. With implementation that allow to pass multiple ...
jcubic's user avatar
  • 67.1k
1 vote
2 answers
85 views

This is from this CS 61A notes about SICP p80~82 about ucblogo (a dialect of Logo, which derived from Lisp): Second, Logo has first-class expressions; you can run a list that you get as an argument. ...
An5Drama's user avatar
  • 774
0 votes
0 answers
70 views

I want to pass values of variable with the same name (say "bindings") between procedures, but have problems with it. For example, I have several procedures like the one below, they all have ...
QianruZhou's user avatar
1 vote
0 answers
74 views

This is one follow-up question of this QA where how syntax-rules works has been known owing to Shawn. As someone told me before, one different question although somewhat related should be posted as ...
An5Drama's user avatar
  • 774
0 votes
0 answers
161 views

This is from SICP exercise 4.9. Exercise 4.9. Many languages support a variety of iteration constructs, such as do, for, while, and until. In Scheme, iterative processes can be expressed in terms of ...
An5Drama's user avatar
  • 774
1 vote
1 answer
71 views

I'm currently taking an undergraduate course in functional programming, and we just learned about environments in Scheme. From what I understand, an environment is the context in which a function is ...
Martician's user avatar
3 votes
4 answers
297 views

Can a recursion with nested calls in tail position be tail recursion? For example, I have the following function in Racket that is intended to convert a binary tree, defined as a nested struct below, ...
Argyll's user avatar
  • 10.1k
0 votes
1 answer
104 views

According to scheme.org Implementations GNU Guile supports the R6 and R7 versions of Scheme. And the guile executable has command line arguments of "--r6rs" and "--r7rs". And the ...
Scooter's user avatar
  • 7,111
1 vote
0 answers
97 views

Everyone says that with call/cc the stack is saved and then restored back when I call the continuation. In literally all answers and questions here, I've never seen a picture of their explanations ...
Curio's user avatar
  • 1,401
1 vote
1 answer
82 views

I am reading SICP section 3.5.1 where it gives the implementation of primitive procedures provided in MIT/GNU Scheme. I tried to load these implementations without considering the order since they are ...
An5Drama's user avatar
  • 774
1 vote
0 answers
90 views

This is one follow-up question of this QA. The comments there focus on how to implement map etc in C++ but doesn't say much about "relationship between environment model" and map etc. SICP ...
An5Drama's user avatar
  • 774
0 votes
2 answers
168 views

When learning SICP, 6.001 lec15 has: A good understanding of the environment model tells me why (IMHO) C++ will never have a fully-functional map, filter, and fold-right/fold-left procedures that are ...
An5Drama's user avatar
  • 774
0 votes
0 answers
58 views

(define (subtractMatHelper list1 acc) (if(null?list1) acc ( (define newList (cons(-(car(car list1)) (car(car(cdr list1)))) acc)) ;the subtraction of the first element inthe ...
maiblynnn's user avatar
2 votes
1 answer
208 views

How does recursive tail call optimization work in regards to what is placed/removed from the call stack? Specifically for LISP like languages? Any insight at assembly level will be helpful. I show ...
notaorb's user avatar
  • 2,220
2 votes
3 answers
92 views

How do I evaluate this code un-deterministically? (cond (correct-1? do-thing-1) (correct-2? do-thing-2) (correct-3? do-thing-3)) For example, if correct-1? and correct-3? are true, then I ...
Daaninator's user avatar
0 votes
1 answer
63 views

I wrote this code to compute the cube root of a number in Scheme: (define (square x) (* x x)) (define (abs x) (if (< x 0) (- x) x)) (define (cube x) (* x x x)) (define (cube-root-itr guess x) (...
Mohammad Abdullah Khan's user avatar
0 votes
1 answer
52 views

The code is as follows: (define (square x) (* x x)) (define (abs x) (if (< x 0) (- x) x)) (define (sqrt-iter guess x) (if (good-enough? guess x) guess (sqrt-iter (improve guess x) x))) ...
Mohammad Abdullah Khan's user avatar
0 votes
0 answers
48 views

Recently when I am coding my homework using Scheme language, I carelessly added one dot. Here is one minimal demo: (define (test value) (vector-map (lambda (elem) (cond ((number?...
An5Drama's user avatar
  • 774

1
2 3 4 5
165