scheme

How would I express this Scheme function more clearly?

(define (repeated f n) if (= n 0) f ((compose repeated f) (lambda (x) (- n 1)))) I wrote this function, but how would I express this more clearly, using simple recursion with repeated? I'm sorry, I forgot to define my compose function. (define (compose f g) (lambda (x) (f (g x)))) And the function takes as inputs a procedu...

Convert this Scheme function into a different form?

So here's one way to define a sum as a message passing object: (define (make-sum . exps) (let ((len (length exps))) ;; first handle variable length operands (cond ((= len 0) (make-number 0)) ;; base case for addition ((= len 1) (car exps)) ;; might as well drop the sum if only 1 argument ((> len 2) ...

Is there a fast language that supports portable continuations?

I'm looking for a fast language (ie. a language that can be compiled natively to achieve performance not more than 3 or 4 times slower than C), which supports portable continuations. By this I mean a continuation that can be serialized on one computer, and deserialized on another. I know that SISC can do this (a Scheme implementation i...

Are there people using scheme out there?

Hey, I have just started to study computer sciences at the university where they teach us programming in scheme. Since i have learned c++ for the last 6 years, scheme appears a little odd to me. But they tell me you can write any program you can write in C or Java with it. Is anybody really using this language? ...

Why does this code not work in Scheme?

(define a 42) (set! 'a 10) (define a 42) (define (symbol) 'a) (set! (symbol) 10) (define a (cons 1 2)) (set! (car a) 10) I tried running them in DrScheme and they don't work. Why? ...

How to use set! in Scheme functions?

How would you use set! in a simple procedure f such that evaluating (+ (f 0) (f 1)) will return 0 if the arguments to + are evaluated from left to right but will return 1 if the arguments are evaluated from right to left? ...

Scheme IDE for Windows

What is a good Scheme IDE for Windows? OK, I'll admit it; I'm not at RMS's level, and don't want to use Emacs or any character-based interface -- I want a graphic IDE with colorization, a REPL, and usable, in-line help for a specific, well-documented dialect of Scheme. I have searched around and PLT Scheme/DrScheme seems the best, but ev...

How to clear an internal list in Scheme?

I have the following code and would like to add a 'clear message that removes all the stored numbers from the internal list. How would I do this? (define (make-stat) (let ((values (list))) (lambda (op . args) (cond ((eq? op 'add) (set! values (cons (car args) values))) ...

Convert string to code in Scheme

How do I convert a string into the corresponding code in PLT Scheme (which does not contain the string->input-port method)? For example, I want to convert this string: "(1 (0) 1 (0) 0)" into this list: '(1 (0) 1 (0) 0) Is it possible to do this without opening a file? ...

What problems are solved with R6RS Scheme's make-variable-transformer?

While looking at the syntax-case section in R6RS, I saw the keyword make-variable-transformer, described as an identifier macro. The example given is very minimal, and I am not groking why it is necessary, or what use-cases require it. Finding additional examples of its use is also proving difficult. Presumably it makes some form of synt...

How would you read input file in Scheme?

I am trying to input data from a .txt file into a scheme structure. Each element is separated by a tab in the data file and each structure set is on a new line. I want to be able to read in the data from one line into a structure and make a list of each structure set in the file. Any suggestions? ...

Scheme Macro for nesting expressions

Can a macro be written in Scheme (with define-syntax, for example) which will take expressions like this: (op a b c d e f g h i j) And yield expressions like this as output? (op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j) Of course, for arbitrary lengths. I can't think of a way to do it, given some template like th...

How is Tail Call Optimization implemented in DrScheme?

I've heard that trampolining is an ineffective way of implementing TCO. How does DrScheme (PLAI Scheme, technically) do it? Does it do it the 'right' way (that is, produce assembly code which directly branches to the tail call, instead of going through the stack and trampolining)? ...

Questions for python->scheme conversion

I currently am trying to write a python program using scheme semantics so I can later translate it into scheme without relying on a lot of pythonic stuff. I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a*, depth first, and breadth first search algorithm. I did this ~11 years ...

What is hard in Java but easy in Scheme?

These two languages are very different. They're each well-suited to their own particular tasks. What tasks are easy to do in Scheme, yet are hard / require lots of ugly code to do in Java? Another way of putting it: what is Scheme better at? If you can think of things that Java is better at, see this question. ...

What is hard in Scheme but easy in Java?

These two languages are very different. They're each well-suited to their own particular tasks. What tasks are easy to do in Java, yet are hard / require lots of ugly code to do in Scheme? Another way of putting it: what is Java better at? If you can think of things that Scheme is better at, see this question. EDIT: This pair of questi...

Implementation of Curried Functions in Scheme

What happens when I do the following? (define ((func x) y) (if (zero? y) ((func x) 1) 12)) I understand that I can do this: (define curried (func 5)) And now I can use curried. What I'm curious about is in the definition of the function. Does the line ((func x) 1) create a new lambda with x as the argument, a...

Compile lisp / scheme in Notepad++

Hi! I'm pretty much into lisp at the moment, and unfortunately i'm only available to code on windows. Is is possible to let Notepad++ take care of the interpreting of my scripts, and display the output in the compiler window? If yes, what interpreter would be the best to use? Thanks! ...

How do you type lisp efficiently, with so many parentheses?

I try to keep my fingers on home row as much as possible. Typing all the parentheses makes me move away from there a fair bit. I use Emacs; the parentheses themselves are no issue, I'm comfortable with them. And I don't like modes that type them for me automatically. I've thought about remapping the square brackets to parentheses an...

Using AND with the apply function in Scheme

Why doesn't the following work? (apply and (list #t #t #f)) While the following works just fine. (apply + (list 1 3 2)) This seems to be the case in both R5RS and R6RS? ...