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.
...
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...
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...
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...
One long term project I have is working through all the exercises of SICP. I noticed something a bit odd with the most recent exercise. I am testing a Huffman encoding tree. When I execute the following code in DrScheme I get the expected result:
(a d a b b c a)
However, if I execute this same code in mzscheme by calling (load "2.67.s...
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...
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...
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...
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)...
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?
...
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 ...
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...
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...
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.
...
> (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?
...
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.
...
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
...
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...
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...
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.
...