scheme

Scheme/Lisp nested loops and recursion

北城以北 提交于 2020-01-01 05:19:32
问题 I'm trying to solve a problem in Scheme which is demanding me to use a nested loop or a nested recursion. e.g. I have two lists which I have to check a condition on their Cartesian product. What is the best way to approach these types of problems? Any pointers on how to simplify these types of functions? I'll elaborate a bit, since my intent might not be clear enough. A regular recursive function might look like this: (define (factorial n) (factorial-impl n 1)) (define (factorial-impl n t)

Implementing Iota in Haskell

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 04:56:05
问题 Iota is a ridiculously small "programming language" using only one combinator. I'm interested in understanding how it works, but it would be helpful to see the implementation in a language I'm familiar with. I found an implementation of the Iota programming language written in Scheme. I've been having a little trouble translating it to Haskell though. It's rather simple, but I'm relatively new to both Haskell and Scheme. How would you write an equivalent Iota implementation in Haskell? (let

Implementing Iota in Haskell

若如初见. 提交于 2020-01-01 04:56:01
问题 Iota is a ridiculously small "programming language" using only one combinator. I'm interested in understanding how it works, but it would be helpful to see the implementation in a language I'm familiar with. I found an implementation of the Iota programming language written in Scheme. I've been having a little trouble translating it to Haskell though. It's rather simple, but I'm relatively new to both Haskell and Scheme. How would you write an equivalent Iota implementation in Haskell? (let

How do you load a file into racket via command line?

最后都变了- 提交于 2020-01-01 01:15:37
问题 I have been trying to launch a racket program from the commandline (via 'racket') but have not been having success. According to the documentation (here http://docs.racket-lang.org/reference/running-sa.html#%28part._mz-cmdline%29) passing -f followed by a file should evaluate that file. However, I can't seem to get this to work. As a test, I made the following file: ;test.rkt #lang racket (define a 1) Then, running it in racket (supposedly loading the file) and attempting to recall the value

Why continuation passing style

别说谁变了你拦得住时间么 提交于 2019-12-31 08:58:12
问题 In The Scheme Programming Language by Kent Dybvig (4th edition) section 3.4, he describes very clearly what continuation passing style is. For the why he gives two reasons: pass more than one result to its continuation, because the procedure that implements the continuation can take any number of arguments. CPS also allows a procedure to take separate continuations ..., which may accept different numbers of arguments. Since the first reason can also be done using the values procedure and the

Why continuation passing style

喜你入骨 提交于 2019-12-31 08:58:05
问题 In The Scheme Programming Language by Kent Dybvig (4th edition) section 3.4, he describes very clearly what continuation passing style is. For the why he gives two reasons: pass more than one result to its continuation, because the procedure that implements the continuation can take any number of arguments. CPS also allows a procedure to take separate continuations ..., which may accept different numbers of arguments. Since the first reason can also be done using the values procedure and the

Converting numbers to english letter list

假装没事ソ 提交于 2019-12-31 05:42:10
问题 I have the function below which converts an input of numbers into the partially translated word output of those numbers. Using product and quotient, it adds the word representation of numbers while splitting the number into groups. For example: (number-name 87969087) -> '(87 million 969 thousand 87) (number-name 1000000) -> '(1 million) Im trying to complete my problem by fully translating those numbers which are less than 1000 as well. Im trying to implement a function less-than-1000 which

Removing all duplicate members from a list in scheme

醉酒当歌 提交于 2019-12-31 05:09:34
问题 I am trying to remove duplicates in a list, using recursion. This is what I have. It only removes the first duplicate, not all of them. My idea is to look at the first member, check if its a member of the rest of the list, if so, call the function again. If not, create a list with the first member and the result from calling the function again. I don't understand why it doesn't remove all the duplicates. (define (removeDupes L) (cond ((null? L) ()) ((list? (member (car L) (cdr L)))

Find an element of list in lists in list

怎甘沉沦 提交于 2019-12-31 05:07:08
问题 I need a procedure which takes a list and checks if an element is part of that list even when the list contains lists. So far, I've written this: (define (element-of-set? element set) (cond ((null? set) #f) ((eq? element (car set)) #t) (else (element-of-set? element (cdr set)))))) But, if you have a list that looks like this: (a (a b b (c b) 3) 5 5 (e s) (s e s)) then my written element-of-set? does not recognize that 3 is a part of this list. What am I doing wrong? 回答1: You're not recurring

What interpreter to use while reading SICP? [closed]

一世执手 提交于 2019-12-31 04:45:20
问题 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 5 years ago . I'm reading SICP book available at http://mitpress.mit.edu/sicp/ To run the sample code which interpreter should I use ? I've considered Dandelion Lisp plugin for Eclipse : http://sourceforge.net/projects/dandelion-ecl/ Also considered Scheme for windows http://www.gnu.org/software/mit-scheme/ Which one should I