sicp

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

我与影子孤独终老i 提交于 2019-12-03 12:55:35
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 R5RS implementation. Is this a fault in the implementation, or am I not doing or understanding it right?

Eager evaluation/applicative order and lazy evaluation/normal order

北城以北 提交于 2019-12-03 12:27:34
问题 As far as I know, eager evaluation/applicative order evaluates all arguments to a function before applying it, on the other hand, lazy evaluation/normal order evaluates the arguments only when needed. So, what are the differences between the pair of terms eager evaluation and applicative order , and lazy evaluation and normal order ? Thanks. 回答1: Lazy evaluation evaluates a term at most once, while normal order would evaluate it as often as it appears. So for example if you have f(x) = x+x

How do I get the functions put and get in SICP, Scheme, Exercise 2.78 and on

北城以北 提交于 2019-12-03 09:06:33
问题 I am trying to do exercise 2.78 in SICP, but the functions put and get are unknown. I have tried multiple languages, like pretty big, racket, r5rs, mit-scheme, mzscheme, etc. I even downloaded the SICP support (http://www.neilvandyke.org/sicp-plt/), to no avail. How can I get these functions to work? 回答1: Yes, I found SICP a little annoying sometimes because of stuff like this. Functions that are assumed to exist but don't actually exist make it harder to try to the examples. I wrote my own

No idea how to solve SICP exercise 1.11

故事扮演 提交于 2019-12-03 06:43:33
问题 Exercise 1.11: A function f is defined by the rule that f(n) = n if n < 3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n > 3 . Write a procedure that computes f by means of a recursive process. Write a procedure that computes f by means of an iterative process. Implementing it recursively is simple enough. But I couldn't figure out how to do it iteratively. I tried comparing with the Fibonacci example given, but I didn't know how to use it as an analogy. So I gave up (shame on me) and

What does “Data is just dumb code, and code is just smart data” mean? [closed]

≡放荡痞女 提交于 2019-12-03 04:54:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I just came across an idea in The Structure And Interpretation of Computer Programs: Data is just dumb code, and code is just smart data I fail to understand what it means. Can some one help me to understand it better? 回答1: This is one of the fundamental lessons of SICP and one of the most powerful ideas of

Materials for SICP with python?

这一生的挚爱 提交于 2019-12-03 04:41:09
问题 I want to try out SICP with Python. Can any one point to materials (video.article...) that teaches Structure and Interpretation of Computer Programs in python . Currently learning from SICP videos of Abelson, Sussman, and Sussman. 回答1: Don't think there is a complete set of materials, this is the best I know. If you are up to generating the material yourself, a bunch of us plan to work through SICP collectively at. I know at least one guy will be using Haskell, so you will not be alone in

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

拈花ヽ惹草 提交于 2019-12-03 04:36:40
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? current-milliseconds is a function that returns the current millisecond count from the system, but it

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

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 R5RS implementation. Is this a fault in the

Eager evaluation/applicative order and lazy evaluation/normal order

ε祈祈猫儿з 提交于 2019-12-03 01:58:03
As far as I know, eager evaluation/applicative order evaluates all arguments to a function before applying it, on the other hand, lazy evaluation/normal order evaluates the arguments only when needed. So, what are the differences between the pair of terms eager evaluation and applicative order , and lazy evaluation and normal order ? Thanks. Lazy evaluation evaluates a term at most once, while normal order would evaluate it as often as it appears. So for example if you have f(x) = x+x and you call it as f(g(42)) then g(42) is called once under lazy evaluation or applicative order, but twice

What are the actual differences between Scheme and Common Lisp? (Or any other two dialects of Lisp)

。_饼干妹妹 提交于 2019-12-03 00:41:48
问题 Note: I am not asking which to learn, which is better, or anything like that. I picked up the free version of SICP because I felt it would be nice to read (I've heard good stuff about it, and I'm interested in that sort of side of programming). I know Scheme is a dialect of Lisp and I wondered: what is the actual difference is between Scheme and, say, Common Lisp? There seems to be a lot about 'CL has a larger stdlib...Scheme is not good for real-world programming..' but no actual thing