scheme

What is the exact definition of a Metacircular Interpreter?

Is it legal to call a C compiler written in C or a PHP interpreter written in PHP metacircular? Is this definition valid only for languages of a specific type, like Lisp? In short, what are the conditions that an interpreter should satisfy for being called Metacircular? ...

SICP making change

So; I'm a hobbiest who's trying to work through SICP (it's free!) and there is an example procedure in the first chapter that is meant to count the possible ways to make change with american coins; (change-maker 100) => 292. It's implemented something like: (define (change-maker amount) (define (coin-value n) (cond ((= n 1) 1) ...

Function Table in Scheme using Association List

Hello. I am attempting to build a rudimentary interpreter in Scheme, and I want to use an association list to map to arithmetic functions. This is what i have so far: ; A data type defining an abstract binary operation (define binoptable '(("+" . (+ x y))) ("-" . (- x y)) ("*" . (* x y)) ("/" . (/ x y))) ) The problem is...

Learning Scheme Macros. Help me write a define-syntax-rule

I am new to Scheme Macros. If I just have one pattern and I want to combine the define-syntax and syntax-rules, how do I do that? (define-syntax for (syntax-rules (from to) [(for i from x to y step body) ...] [(for i from x to y body) ...])) If I just have one for, how do I combine the syntax definition and the rule? Thanks...

how can I make vim send command to gnu screen session

I am trying to figure out how to script vim to send a message to a gnu screen "window". i.e. I have a screen session open and in one window I have a vim session and in the other a scheme interpreter. When I save my vim session I would like it to restart the interpreter in the other window loading in the new environment. I can figure out ...

Can someone explain the following Scheme code?

I have been listening to Stanford's programming paradigm lecture series, but I'm confused by the following code (from lecture 20). Would someone explain, line by line, what this is doing? Thanks. (define (flatten sequence) (cond ((null? sequence) '()) ((list? (car sequence)) (append (flatten (car sequence)) (flatten (cdr sequence)))) (...

two methods of composing functions, how different in efficiency?

Hi, Let f transform one value to another, then I'm writing a function that repeats the transformation n times. I have come up with two different ways: One is the obvious way that literally applies the function n times, so repeat(f, 4) means x → f(f(f(f(x)))) The other way is inspired from the fast method for powering, which means div...

Does anyone use the Scheme programming language for a living?

I started learning Scheme for fun, and was wondering if anyone uses it for a living as a prime programming language... or even as an additional tool to the programming arsenal? If so, what do you use it for? What kind of problems do you typically solve with it? ...

Why does Clojure have "keywords" in addition to "symbols"?

I have a passing knowledge of other Lisps (particularly Scheme) from way back when. My knowledge is pretty rusty (and was pretty basic to begin with). Recently I've been reading about Clojure. I see that it has both "symbols" and "keywords". Symbols I'm familiar with, but not keywords. Do other Lisps have keywords? How are keywords diff...

What is ' (apostrophe) in Lisp / Scheme?

I am on day 1 hour 1 of teaching myself Scheme. Needless to say I don't understand anything. So I'm reading The Little Schemer and using this thing: http://sisc-scheme.org/sisc-online.php as an interpreter. I need to use ' for, for example (atom? 'turkey) to avoid an "undefined variable" error. The ', according to the book, is a...

do any one use Dr scheme programming? how to sort using list?

which data structure to use to sort n numbers in dr scheme i m not allowed to use vector and structure ..if i use list i cant edit the list values .so how can i sort n numbers . the language i use is textual mzscheme rsr5 ...

Embedding IronScheme in a C# app

...

How does PLTScheme Catch errors?

I am amazed by the "error" function in PLTScheme. If I have a division by zero, it doesnt do any other recursion and just comes out of the call stack and give me an error. Is there an implicit continuation before all the functions? Does the error throw away the call stack? Does anybody have any idea about this? ...

Lisp: How to write a Higher Order Function

I have this problem to work on: The sum higher order procedure can be generalised even further to capture the idea of combining terms with a fixed operator. The mathematical product operator is a specific example of this idea, with multiplication replacing the addition of the summation operator. The procedure accumulate, started below, ...

Scheme regular expression match

Is there a simpler way of writing in scheme (eqv? (regexp-match "0x" "0x1234") #t) #f (eqv? (regexp-match "0x" "1234") #f) #t ...

Question on Scheme with Best First Search algorithm

Okay this is a homework question, and I just don't have a clue how I suppose to start. Some help and hints will be much appreciated. I need to use a heuristic function to solve a maze type problem. Suppose I have a 5x5 grid, and a robot in position (1,5) and my goal is to move the robot to (5,1). Along the way there are few obstacles...

Scheme How To Test 2 Conditions in one Clause ?

I need to create a sub-function that will return me all the adjacent node, which I needed for this question in Scheme. I'm new to scheme, not sure how I can combine two conditions into one test case ? Basically my algorithm is to test if the node is on the edge or not. This case I use a 5x5 grid. If both node is on the corner meaning ...

Scheme How To Return Multiple Values?

I notice that almost all scheme functions can only return one list as output. In the following, I would like to return multiple values of all the adjacent nodes of neighbors. (define (neighbors l w) (if (and (= 1 l) (= 1 w)) (list (and (l (+ 1 w))) (and (+ 1 l) w)))) ; how to output 2 or more values? In this case I'm first t...

How to Assign Mulitpule Caulated Value Into List in Scheme

Okay this is my 4th question today on Scheme, still pretty new to Scheme, as I needed for one of my sub-function I asked earlier in the day. Basically this will return me the difference of 2 lists. Say you've got (1,5) and (5,1) this function should return me 8. As that's the distance between l to w Here is what I have. Note: if I cha...

Scheme How to Take the first item in the List ?

Say I want to take the first item of the lists '(4 3 1) '(5 6 8) I want something like this (first '(4 3 1) '(5 6 8)) should return me the first item (4 3 1) as result. Is there something like this in scheme build-in function I can call ? car doesn't work, as it only returns me the first item inside 1 list list-ref doesn't work,...