sicp

How do you find where an error has occurred in MIT scheme?

。_饼干妹妹 提交于 2019-12-11 06:16:21
问题 When you get an error in MIT scheme it doesn't tell you where the error occurred. For example, it just prints something like this: ;Unbound variable: top-left ;To continue, call RESTART with an option number: ; (RESTART 3) => Specify a value to use instead of top-left. ; (RESTART 2) => Define top-left to a given value. ; (RESTART 1) => Return to read-eval-print level 1. How do I find where this error occurred in my code? 回答1: In mit-scheme, if you are using the REPL from a shell, you can call

What's the relationship between streamjs and linqjs

可紊 提交于 2019-12-11 01:29:29
问题 After reading SICP, I recently discovered streamjs. The developer referenced linqjs as an alternate implementation with different syntax, but I can't make the connection. How do the methods in streamjs map to those in linqjs? 回答1: I haven't used either library, but, here's my initial analysis (I've read quite a bit of SICP, but not the whole thing admittedly). stream.js is an implementation of a functional style data structure for a list. Many data structures in a functional language tend to

Understanding bound and free variables in LISP

二次信任 提交于 2019-12-10 19:29:35
问题 I'm reading SICP , and the topic of bound and free variables has come up. However, I am confused about it. Does the term "bound variables" only apply to variables that are formal parameters? In addition, the text says that a procedure definition "binds" its formal parameters. This confuses me with the fact that some people say that we "bind" a value to a variable. Obviously, the term seems to mean different things when we're talking about different types of variables. Could someone clear up

applicative-order/call-by-value and normal-order/call-by-name differences

前提是你 提交于 2019-12-10 10:38:54
问题 Background I am learning the sicp according to an online course and got confused by its lecture notes. In the lecture notes, the applicative order seems to equal cbv and normal order to cbn. Confusion But the wiki points out that, beside evaluation orders(left to right, right to left, or simultaneous), there is a difference between the applicative order and cbv: Unlike call-by-value, applicative order evaluation reduces terms within a function body as much as possible before the function is

Scheme, SICP, R5RS, why is delay not a special form?

三世轮回 提交于 2019-12-09 10:29:03
问题 This is concerning chapter 3.5 from SICP, in which streams are being discussed. The idea is that: (cons-stream 1 (display 'hey)) Should not evaluate the second part of the cons-stream, so it should not print “hey”. This does happen, I get the following output: hey(1 . #< promise >) So my conclusion is that delay is not implemented as a special form? Or am I doing something wrong? I use the following implementation: (define (cons-stream a b) (cons a (delay b))) With delay being the default

Is there an equivalent to Lisp's “runtime” primitive in Scheme?

大憨熊 提交于 2019-12-09 05:04:30
问题 According to SICP section 1.2.6, exercise 1.22: Most Lisp implementations include a primitive called runtime that returns an integer that specifies the amount of time the system has been running (measured, for example, in microseconds). I'm using DrScheme, where runtime doesn't seem to be available, so I'm looking for a good substitute. I found in the PLT-Scheme Reference that there is a current-milliseconds primitive. Does anyone know if there's a timer in Scheme with better resolution? 回答1:

Examining the internals of the functions in Haskell

北城余情 提交于 2019-12-08 18:53:34
问题 I am a Haskell newbie, though had a previous Lisp/Scheme experience. Right now I am looking at the examples from SICP and trying to implement them in Haskell to get more hands-on experience. In the lecture 3b authors present a function for computing the derivatives symbolically. It contains, among others, the following lines: (define (deriv exp var) (cond ((constant? exp var) 0) ((same-var? exp var) 1) ; ... Further in the lecture, some more functions are defined: (define (constant? exp var)

Error setting load-noisily? and auto-exiting in MIT-Scheme

帅比萌擦擦* 提交于 2019-12-07 20:28:38
问题 In order to debug MIT-Scheme scripts with Vim, I want to be able to run the script file currently being edited as conveniently as possible. Here is what I'm doing: sicp.scm (set! load-noisily? #t) (define (abs x) (cond ((> x 0) x) ((= x 0) 0) ((< x 0) (- x)) ) ) (abs 42) (abs -24) (exit) After executing :!mit-scheme --eval "(load \"sicp\")" when editing sicp.scm in Vim, I get: Image saved on Saturday May 17, 2014 at 2:39:25 AM Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR

How to install sicp package module in racket?

两盒软妹~` 提交于 2019-12-07 14:04:36
问题 I'm newbie in programming world. I'm using ubuntu OS. I have started my journey with sicp book. I'm working with scheme repl . But suddenly I get stuck with section 2.2.4 I'm not able to execute it's example with scheme repl . I tried to run given example of section, I got an error as given below 1 ]=> (define wave2 (beside wave (flip-vert wave))) ;Unbound variable: wave Even In book, painter is given as primitive procedure. when I ran it, it thrown an error too 1 ]=> painter ;Unbound

applicative-order/call-by-value and normal-order/call-by-name differences

巧了我就是萌 提交于 2019-12-06 16:03:57
Background I am learning the sicp according to an online course and got confused by its lecture notes. In the lecture notes, the applicative order seems to equal cbv and normal order to cbn. Confusion But the wiki points out that, beside evaluation orders(left to right, right to left, or simultaneous), there is a difference between the applicative order and cbv: Unlike call-by-value, applicative order evaluation reduces terms within a function body as much as possible before the function is applied. I don't understand what does it mean by reduced. Aren't applicative order and cbv both going to