plt-scheme

What are some things that you've used Scheme macros for?

Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I'm looking for some more exotic uses of macros, particularly in PLT Scheme. I'd like to get a feel for when to consider using a macro vs. using functions. ...

Time Code in PLT-Scheme

I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this: > (define (loopy times) (if (zero? times) 0 (loopy (sub1 times)))) > (loopy 5000000) 0 ;(after about a second) > (timed (loopy 5000000)) Took: 0.93 se...

How do I choose what language to use in DrScheme?

I recently downloaded PLT Scheme and DrScheme. When I open DrScheme, I am told to choose a language. However, I'm not familiar with any of my options, and the help guides don't really break it down to help me easily choose which choice. So, first - is DrScheme and PLT Scheme really the tools I need to learn Lisp and/or Scheme? If so, wh...

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...

Assigning a list of atoms in Scheme

I'm trying to learn Scheme from the book "The Little Schemer" using DrScheme on a Macintosh. It starts with things like "What is the car of l where l is the argument (a b c)?" I understand that the answer to this question is a, but I'm not able to actually figure out what to type into Dr Scheme to "follow along". A simple idea on how t...

Text editor / IDE for Ruby similar to DrScheme

For those who haven't used DrScheme, window is split in two parts: one part is a file you're editing, and the other is interactive shell. When I run a file, it is loaded into interactive environment, so I can invoke functions I've defined etc. Interactive environment still has all the features of text editor (syntax highlighting, auto co...

Why doesn't Scheme support first class environments?

Hi guys, I've been reading through SICP (Structure and Interpration of Computer Programs) and was really excited to discover this wonderful special form: "make-environment", which they demonstrate to use in combination with eval as a way of writing modular code (excerpt from section 4.3 on "packages"): (define scientific-library (make...

How can you re-define a constant identifier in DrScheme?

I am using DrScheme to write a Scheme interpreter. I define a Read Eval Print Loop and I am re-defining the eval procedure. This works fine in other scheme implementations like Chez Scheme, but I don't like the code editing in Chez Scheme, so I would like to use DrScheme for this. When I make a definition such as: (define (eval exp env)...

How do you halt in DrScheme's implementation of R5RS?

When using DrScheme with R5RS, there is no error function. I plan to write my own, but can't figure out how to halt the program execution. I tried commands such as: (halt) (exit) (error) and none worked. How do you halt program execution? ...

Seeking Simply Scheme idioms for Dr. Scheme

I'm working my way through SICP, using both the Ableson/Sussman lectures and the Berkeley 61A lectures, which are far more my speed. I'd like to do some of the Berkeley homework, but need the definitions for sentence, butfirst, butlast and so forth. It looks like at one time there was a simply scheme language built in to Dr. Scheme, but ...

How to write a scheme function that takes two lists and returns four lists

I have 2 lists of elements '(a b c) '(d b f) and want to find differences, union, and intersection in one result. Is that possible? How? I wrote a member function that checks if there is a car of the first list in the second list, but I can't throw a member to the new list. (define (checkResult lis1 lis2) (cond........... )) (checkr...

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...

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. ...

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 load library to support hashtable in R5RS language (DrScheme)?

Looks like R5RS language in DrScheme does not come with hashtable library.. when I run (make-hash-table) it throws an error... Pretty Big has support for hashtable but does not support mutable pairs.. so I am stuck making one of them work for me .. How do I add support for hashtable in R5RS? thanks ...

How to draw points,lines and get coordinates in canvas in PLT scheme ?

Hi, I am newbie in PLT scheme (using DrScheme). So, this question may be annoying to many developers. I want to draw points in every click (mouse event) in a canvas and get the coordinate of that point. Also I want to draw a line from the last point to the last mouse event point. As per documentation, they suggested to use world.ss (in...

Im trying to access a N dimensional vector but I get into infinite recursion.

I want to access a n-dimensional vector but somehow (empty? '()) keeps returning false. ;; access n dimensional vectors ;; (access-nd vector a-list-of-numbers) -> element ;; (access-nd (vector (vector 'x 'y) 'a 'b)) 0 1 ) -> x (define (access-nd avector . alist) (cond ((and (not(empty? alist)) (vector? avector)) (vector-re...

How to save and sort coordinates (of points) in scheme ?

Hi, I want to save coordinates of points (X,Y) in a list. Also I want to sort the list by X or Y value every time I add points in that list. How can I do that? Thanks in advance. ...

Loop in PLT Scheme

Hi, How can I implement loop in plt-scheme like in java- for(int i=0;i<10;){ for(int j=0;j<3;){ System.out.println(""+j); j++; } System.out.println(""+i); i++; } Thanks in advance. ...

Fetch elements from List in scheme

Hi, How to go through a list or fetch element from a list in scheme? How can I name each element (like we do for variables in java) in a list? Thanks in advance. I want to compare every point in a list to another point. So, as we do in java or python- for(int i;i<list.size();i++){ if (list[i]> k){ //do something } ...