scheme

How is “letrec” implemented without using “set!”?

最后都变了- 提交于 2019-12-22 06:29:35
问题 How can letrec be implemented without using set! ? It seems to me that set! is an imperative programming construct, and that by using it, one loses the benefits of functional programming. 回答1: I know usually we ask content to be copied but there is no short answer to your question. http://www.cs.indiana.edu/~dyb/pubs/fixing-letrec.pdf 回答2: No. Just because a functional feature is implemented with imperative code behind the scenes, that doesn't make the feature be imperative. Our computing

How is “letrec” implemented without using “set!”?

て烟熏妆下的殇ゞ 提交于 2019-12-22 06:29:10
问题 How can letrec be implemented without using set! ? It seems to me that set! is an imperative programming construct, and that by using it, one loses the benefits of functional programming. 回答1: I know usually we ask content to be copied but there is no short answer to your question. http://www.cs.indiana.edu/~dyb/pubs/fixing-letrec.pdf 回答2: No. Just because a functional feature is implemented with imperative code behind the scenes, that doesn't make the feature be imperative. Our computing

Benefits of learning scheme?

孤街醉人 提交于 2019-12-22 01:25:37
问题 I've just started one of my courses, as classes just began 2 weeks ago, and we are learning Scheme right now in one for I assume some reason later on, but so far from what he is teaching is basically how to write in scheme. As I sit here trying to stay awake I'm just trying to grasp why I would want to know this, and why anyone uses it. What does it excel at? Next week I plan to ask him, whats the goal to learn here other than just how to write stuff in scheme. 回答1: It's a functional

scheme string-append? recursion to replicate a string

浪尽此生 提交于 2019-12-21 21:25:24
问题 Design a program called string-dup that consumes a String s and a Number n and returns a String that is the concatenation of s n times with spaces between each instance of s, i.e., (string-dup "a" 3) => "a a a" Without using replicate but i guess we can use string-append. So far i got (define (string-dup s n) (cond [(zero? n) ""] [else (cond [(= n 1 ) s] [(> n 1 )(string-dup (string-append s " ") (sub1 n))])])) However, this only allows me to have one string "a". I know when in the list case

Scheme, When to use Symbols instead of Strings?

主宰稳场 提交于 2019-12-21 18:59:13
问题 I apologize in advance for my primitive english; i will try my best to avoid grammatical errors and such. Two weeks ago i decided to freshen my knowledge of Scheme (and its enlightnings) whilst implementing some math material i got between hands, specifically, Regular Languages from a course on Automata theory and Computation in which i am enrolled. So far, i've been representing alphabets as lists of symbols instead of lists of chars because i want to have letters of variable size. lists of

Scheme, When to use Symbols instead of Strings?

耗尽温柔 提交于 2019-12-21 18:57:22
问题 I apologize in advance for my primitive english; i will try my best to avoid grammatical errors and such. Two weeks ago i decided to freshen my knowledge of Scheme (and its enlightnings) whilst implementing some math material i got between hands, specifically, Regular Languages from a course on Automata theory and Computation in which i am enrolled. So far, i've been representing alphabets as lists of symbols instead of lists of chars because i want to have letters of variable size. lists of

How to split list into evenly sized chunks in Racket (Scheme)?

穿精又带淫゛_ 提交于 2019-12-21 17:35:13
问题 Example: How to convert list: '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) Into list of lists: '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12 13 14 15)) Based on answers provided here so far, this is what I've come up with: First define function to take up to 'n' elements from beginning of the list: (define (take-up-to n xs) (define (iter xs n taken) (cond [(or (zero? n) (empty? xs)) (reverse taken)] [else (iter (cdr xs) (- n 1) (cons (car xs) taken))])) (iter xs n '())) Second is similar function for the

Is IronScheme interpreted or compiled? Does it benefit from .NET Framework optimizations?

核能气质少年 提交于 2019-12-21 16:53:47
问题 In the book "IronPython in Action," the author states that IronPython, unlike CPython, benefits from certain optimizations, both in the JIT and in the framework itself, that CPython cannot take advantage of. Consequently, IronPython is potentially faster than CPython is, especially for multithreading scenarios. Does IronScheme benefit from such optimizations? Is it an interpreter (not a compiler), and is it an interpreter because that's the nature of Lisp, that it must be interpreted to

Why is there no tail recursion optimization in Emacs lisp, not but like other scheme?

我的未来我决定 提交于 2019-12-21 12:44:31
问题 Emacs lisp is a dialect of LISP and especially Scheme. Most of scheme interpreters do have a optimization of Tail Recursion, but emacs lisp doens't. I searched the reason in `info elisp' for a while, but I fail to find it. P.S. Yes, there is other iteration syntax in elisp like `while', but I still cannot find a good reason why they didn't implement tail recursion like other scheme interpreters. 回答1: Emacs Lisp was created in the 1980's. The Lisp dialect that the Emacs author (Richard

What is the Scheme function to find an element in a list?

故事扮演 提交于 2019-12-21 12:07:13
问题 I have a list of elements '(a b c) and I want to find if (true or false) x is in it, where x can be 'a or 'd, for instance. Is there a built in function for this? 回答1: If you need to compare using one of the build in equivalence operators, you can use memq, memv, or member, depending on whether you want to look for equality using eq?, eqv?, or equal?, respectively. > (memq 'a '(a b c)) '(a b c) > (memq 'b '(a b c)) '(b c) > (memq 'x '(a b c)) #f As you can see, these functions return the