scheme

ruby method for atom? in scheme

I'm trying to do the exercises in "The Little Schemer" using Ruby. I'd like to know the equivalent method of atom? in Scheme for Ruby. atom? is a method that returns true if the argument passed in is an atom and returns false otherwise. From what I understand, an atom can be a string of characters or a number. It can't be a list. ...

I can't find my error in this Scheme program for calculate PI

I am doing a Monte Carlo experiment to calculate an approximation of PI. From SICP: The Monte Carlo method consists of choosing sample experiments at random from a large set and then making deductions on the basis of the probabilities estimated from tabulating the results of those experiments. For example, we can approx...

What Lisp is better at parsing?

I'd like to implement a Lisp interpreter in a Lisp dialect mainly as a learning exercise. The one thing I'm thrown off by is just how many choices there are in this area. Primarily, I'm a bit more interested in learning about some of the Lisps that have been around a while (like Scheme or Common Lisp). I don't want to use Clojure to d...

Functional GLUT?

I'm learning a bit of functional programming in Gambit-C Scheme by restricting myself to not using set!. I thought it might be fun to write a little OpenGL game using this environment, which seems to lend itself well to game development. However, it seems to be difficult to stick to a functional style and avoid global state when using ...

Scheme Factorial (fact* l) Question

I'm a newbie at Scheme, so forgive the question: I have a function that calculates the factorials of a list of numbers, but it gives me a period before the last number in the results. Where am I going wrong? code: #lang scheme (define fact (lambda (n) (cond ((= n 0) 1) ((= n 1) 1) (else (* n (fact (-...

Is IronScheme suitable for working through SICP?

Will there be any incompatibilities with the code in SICP if I use IronScheme? ...

How to parse out base file name using Script-Fu

Using Gimp 2.6.6 for MAC OS X (under X11) as downloaded from gimp.org. I'm trying to automate a boring manual process with Script-Fu. I needed to parse the image file name to save off various layers as new files using a suffix on the original file name. My original attempts went like this but failed because (string-search ...) doesn't ...

Quotation in Scheme

Following is a exercise from SICP. I couldn't figure it out on my own. Can some why help me understand? Type following code into interpreator: (car ''abracadabra) And it print out 'quote'. Why? ...

Undefined function in DrScheme?

Hey i'm just trying to write some code in DrScheme: ((function (x) (* x x)) 2) but i got a message saying: reference to undefined identifier: function I'm using language "Essentials of Programming languages (3rd ed.)" and the version of DrScheme is 4.2.1 Thanks! ...

Is Clojure closer to Scheme or Common Lisp from a beginner's perspective?

If I want to learn Clojure, should I start by learning Scheme or Common Lisp? Or is Clojure different enough from both of these, that I should just start learning Clojure by itself? ...

Compiling MIT Scheme on Ubuntu 9.04

When I run ./configure I receive: configure: running /bin/bash ./configure '--prefix=/usr/local' --cache-file=/dev/null --srcdir=. Unknown machine type: none configure: error: ./configure failed for compiler This is on a Lenovo laptop with 4GB of memory. Linux shllaptop 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 x86...

random number generation inside a vector

Hello Under scheme I want to generate a vector of random numbers, I have tried this like this: (make-vector 10 (random 100)) and the output for this is such: #(44 44 44 44 44 44 44 44 44 44) so it seems like it uses the same seed for the generated items, how can I overcome this problem of generating n amount of randomly generated n...

difference between structural recursion and accumulative recursion

I have been learning scheme and I like to know the difference between the two. Thanks. ...

Best way to write portable Scheme code?

In Common Lisp I can conditionally exclude or include code for different implementations like this: #+sbcl (use-sbcl-cool-feature) #-sbcl (use-my-own-not-so-cool-version) This way I can write portable code by isolating the non-portable bits. How can this be done in Scheme? Is there a way to ask the Scheme interpreter or compiler its...

scheme list equivalence comparison

Hello I need to check if two lists have same elements in same order but I wasn't able to achieve as it seems like scheme eq? and eqv? checks by reference so giving false to such: > (eq? (list 1 2 3) (list 1 2 3)) #f > (eqv? (list 1 2 3) (list 1 2 3)) #f How to achieve this ? ...

Scheme equivalent to Haskell where clause

I am just learning scheme, but I would love to be able to repeat myself less. Is there a way I can assign a name to a subexpression in the local scope? As per the comment: Haskell where clause x = s * t where s = 10 t = 20 x should be 200 in this case. ...

How do I tell if the value of a variable is a symbol bound to a procedure in Scheme?

I am familiar with Common Lisp and trying to learn some Scheme, so I have been trying to understand how I'd use Scheme for things I usually code in Common Lisp. In Common Lisp there's fboundp, which tells me if a symbol (the value of a variable) is bound to a function. So, I would do this: (let ((s (read))) (if (fboundp s) (app...

Cons of first class continuations

What are some of the criticisms leveled against exposing continuations as first class objects? I feel that it is good to have first class continuations. It allow complete control over the execution flow of instructions. Advanced programmers can develop intuitive solutions to certain kind of problems. For instance, continuations are used...

Scheme: Extract every number in the list and reconstruct the list?

This is a homework question, but I really just need some hints, that's all. Basically, I need to create this function flat that's supposed to re-contract a new list from the input list (but here, the input list can have a nested list inside): ex. flat of (A (B (C) D) A) is (A B C D A) My algorithm is the following, not sure if it's co...

Scheme Compare item or list if it's inside the test list (can be nested)

Another hw question, here is what I have so far. My Goal is to make the function part? return true if a list or an item is inside the nested list. But so far I can only get it working with signal item inside a first order list. (not nested list yet) (define part? (lambda (item l) (and (not (null? l)) (or (= item (car l...