scheme

How to set up MIT Scheme for 6.001 in Ubuntu 8.10

I play to self-study 6.001 with the video lectures and lecture handouts. However, I have some problems setting up MIT Scheme in Ubuntu (intrepid). I used package management and installed MIT-Scheme, but it's obviously the wrong version to use. It should be 7.5.1 instead of 7.7.90 I followed the instructions from this website (http://oc...

What is the best way to automatically transpose a LilyPond source file into multiple keys?

problem I'm using LilyPond to typeset sheet music for a church choir to perform. Depending on who is available on any given week, songs will be played in various keys. We have an amazing pianist who can play anything we throw at her and the guitarists will typically pencil in alternate chords, but I want to make things easier by having...

What happens in a Scheme 'cond' clause when the 'else' is omitted?

I'm in the process of learning Scheme. I recently spent (too much!) time trying to find a bug in a program before I realized I was missing the 'else' word in a cond clause. But the behavior in such circumstances appears to be a little weird. Experimenting with the conditions with just a simple program (below) the 'whatever' gets display...

How do i invoke Scheme number functions from SICP

In SICP, (ex 2.6) the following functions are described as ways of 'getting by without numbers'. I'm scratching trying to understand this. As a starting point, how do these functions get invoked? Can I actually apply them in some way where the output will be 1? (Or any other number?) (define zero (lambda (f) (lambda (x) x))) (define ...

Functional: construct a list of integers 1..n

This is not homework. I'm learning Standard ML on my own. I know a bit of Scheme, too, so this question ought to be answerable in either language. My self-imposed assignment is to write a function that constructs a list of integers from 1 to n. For example, list(7) should return [1,2,3,4,5,6,7]. An O(n) solution would be ideal. It's ea...

Why higher order procedures??

So if a language provides higher order procedure then I can have procedure that returns procedure... something like (define (Proc a b c) (lambda (x) ( // method body here in terms of a b c and x))) To create new proc I would just do something like.. (define ProcA (Proc a1 b1 c1)) // Would create ProcA that has 1 argument Similar task...

how to use built in list function "filter"

Please help me with using the DrScheme built-in function "filter". "create a function "hello" that consumes a number 'Max', and a list of numbers 'L', produce a list of numbers in 'L' that are smaller than 'Max'." edit Taken from the comments for formatting this is what i have so far (define (smaller? n Max) (cond [(> Max n...

How does code written in one language get called from another language

This is a question that I've always wanted to know the answer, but never really asked. How does code written by one language, particularly an interpreted language, get called by code written by a compiled language. For example, say I'm writing a game in C++ and I outsource some of the AI behavior to be written in Scheme. How does the c...

What's the minimal set of sequence "primitives" required for any sequence computations?

I am writing a Scheme-like in interpreter. It seems natural that the Scheme-like interpreter ought to work well with any object that implements IEnumerable. The interpreter does not allow for mutation - no functions with side effects are exposed. Because IEnumerable is not cloneable, (see here ), I can't implement iteration over the l...

What is the optimal "most general unifier" algorithm?

The Question What is the most efficient MGU algorithm? What is its time complexity? Is it simple enough to describe as a stack overflow answer? I've been trying to find the answer on Google but keep finding private .PDFs that I can only access via an ACM subscription. I found one discussion in SICP: here Explanation of what a "most ...

Expresion Simplification

I have this code to calculate derivatives: (define (diff x expr) (if (not (list? expr)) (if (equal? x expr) 1 0) (let ((u (cadr expr)) (v (caddr expr))) (case (car expr) ((+) (list '+ (diff x u) (diff x v))) ((-) (list '- (diff x u) (diff x v))) ((*) (list '+ (list '* u (diff x v...

How do I execute a .scm script (outside of the REPL) with MIT-Scheme?

I want to type something like 'scheme file.scm' and have it interpret the file, and then take me back to my shell, rather than loading it in the REPL. edit: I tried scheme < test.scm and it still uses the REPL, the only difference is that scheme exits when the stream ends. ...

What is a 'thunk', as used in Scheme or in general?

Hi all, I come across the word 'thunk' at a lot of places in code and documentation related to Scheme, and similar territories. I am guessing that it is a generic name for a procedure, which has a single formal argument. Is that correct? If yes, is there more to it? If no, please? For eg. in SRFI 18, in the 'Procedures' section. ...

Designing SQL alternative?

I'm thinking of designing & implementing my own SQL-equivalent (DDL+DML) that is... a pure relational algebraic language, and has an elegant Lisp-/Scheme-like syntax Assuming an RDBMS such as MySQL, where exactly would I need to start my language design work? On top of the storage engine layer such as InnoDB? I don't know what all R...

What is implicit recursion?

What is implicit recursion? How is it different from explicit recursion? ...

Which language in DrScheme for SICP?

Hi, I have been using the Module for SICP in DrScheme 4.2 but which language has the best support for SICP in DrScheme? Has anyone here tried this? Thanks. ...

Difference between eq? and = in Scheme?

> (eq? 1 1) #t > (eq? 1.1 1.1) #f > (= 1.1 1.1) #t This is the interaction window in DrScheme. Could somebody please explain the difference between = and eq? in Scheme? ...

How do I Extract the First character of a symbol in scheme?

I want it to extract all the words that have a letter e in them. eg. (ewords '(i e ee o oo)) -> '(e ee) Berkeley's 61a lecture uses (first 'word) to extract the first character of the word. However DrScheme screams at me when I try to do that. How do take the first character of the word? like (first 'word)->'w. ...

How do I Apply an Anonymous Function from a List in Scheme?

Hi, I am learning Scheme. What is wrong with the code below?I want to write a program that takes the first function from the list and then applies that to a number? (define num 3) ;;I want to do something like this which returns 3 ((λ (x) x)num) ;;but my functions are in a list so this should return3 ((first '((λ...

What is point free style in Functional Programming?

A phrase that I've noticed recently is the concept of "point free" style... First, there was this question, and also this one. Then, I discovered here they mention "Another topic that may be worth discussing is the authors' dislike of point free style." What is "point free" style? Can someone give a concise explanation? Does it have s...