racket

Pros and cons of MIT Scheme and DrScheme to study SICP?

All, In your mind, what are the pros and cons of using MIT Scheme versus DrScheme, in the context of trying to go through SICP (presumably simultaneously to watching some / all the MIT 6.001 videos)? Please feel free to edit below: MIT Scheme pros: - Specifically built for SICP and MIT 6.001. MIT Scheme cons: DrScheme pros: - Wid...

GTK/Qt On PLT Scheme

Hello, When you compile something written in PLT Scheme on Linux that have a GUI the final will be in a grey(default) theme of Linux, but I want to know If it's possible to integrate PLT Scheme with GTK or Qt? How to do this? Example of grey(default) theme: Thanks. ...

PLT-Scheme.......Sets as objects

Ok so I am trying to make a "make-set" program using objects. I have all ready programmed all the basic procedures for sets like union and intersect and member-of so this is what i ahve so far for my make-set program using object: (define make-set (lambda () (let ((s '())) (lambda (msg e) (case msg ('add (set!...

PLT Scheme: Evaluate a string, or list of strings?

If I do a: (regexp-split (regexp " ") "look tom") I get ("look" "tom") Which is fine, but I can't eval that. If I try to (eval-string) it [which is inside mzlib/string], it errors out, saying that 'tom' isn't defined. I guess it's trying to run: (look tom) Which isn't correct either. Any tips here? ...

Can I have a co-routine of three functions using continuations in Scheme?

Is it possible to add another function procC in here so that the sequence of evaluation is procA->procB->procC->procA ... ? (define (procA another-fun) (let loop ((n 5)) (display "In Proc A \n") (set! another-fun (call/cc another-fun)) (when (> n 0) (loop (- n 1))))) (define (procB another-fun) (let loop ((n 5)) ...

What does 'parametrize' do in DrScheme?

I'm trying to make sense of the example code here (below Examples). I don't understand that parametrize construct. The docs for it are here, but they don't help. What does it do? ...

"set!: not an identifier in:..." plt scheme error.

what's wrong with this code in Dr.Scheme using Pretty Big? i seem to remember doing similar things in the past with no problem. (lambda (x y) (set! (Frame-variables res) (append (Frame-variables res) (list (cons x y))))) which returns the following error: set!: not an identifier in: (Frame-variables res) if i omit the (set! (Fra...

Importing struct with plt scheme

Hi ! I'm struck on a problem with a simple scheme application. In one file (dataloader.ss), I define a struct : (define-struct book-category (id name books)) But I can't use the structure in another file. What I try is, in dataloader.ss, to export the structure with (provide book-category) And in the other file, I import : (requi...

Using _bitmask from PltScheme FFI

This is a part of a plt-scheme wrapper library: (define InputMask (_bitmask '(NoEventMask = #x00000000 KeyPressMask = #x00000001 KeyReleaseMask = #x00000002 ... OwnerGrabButtonMask = #x01000000) _long)) The thing is I cant figure out ho...

Function in Scheme that checks whether the length of a list is even

Hi I have edited the code for function in scheme that checks whether the length of a list is even. (define even-length? (lambda (l) (cond ((null? l)#f) ((equal? (remainder (length(l)) 2) 0) #t) (else #f)))) Is it corrrect? ...

Assigning the result of an expression to a variable

Working with DrScheme (language-- Pretty Big). Trying to pass the result of an expression to a variable that can later be used in another expression. Here is a simplified version of the problem: Definitions window: (define (tot a b c) (+ a b c)) (define (tot2) (+ (tot a b c) 1)) Interpreter window > (tot 5 6 7) 18 > (tot2) . ....

A function in Scheme to replace all occurences of an element in a list with another element

Hi! I am able to delete the element from a list, but I have no idea how to write a function in Scheme to replace all occurences of an element in a list with another element. Any help will be appreciated. ...

Help understanding Continuations in Scheme

I have been working alongside The Little Schemer to learn Scheme and using PLT-Scheme for my environment. The Little Schemer has helped me tremendously with recursion (it is straightforward for me now) but I'm stuck on a portion of the book that introduces "collectors" and calls the function as a whole a continuation. Here is the examp...

Scheme max on sub lists

I've written a function to get the maximum value from a list of nested lists, I have the general form of the function down right; it works on flat lists and nested lists but seems to fail when there are sibling nested lists. Here is my code: (define (multi-max array) (cond ((null? array) 0) ((number? (car array)) (if (>...

PLT Scheme: Converting one of the macros in 'Casting SPELs in LISP'.

(defspel game-action (command subj obj place &rest rest) `(defspel ,command (subject object) `(cond ((and (eq *location* ',',place) (eq ',subject ',',subj) (eq ',object ',',obj) (have ',',subj)) ,@',rest) (t '(i cant ,',command like that.))))) Tha...

How to bind "rest" variables to list of values in macro in Scheme

I want to make a helper macro for writing match-extensions. I have something like this: (define-match-expander my-expander (λ (stx) (let* ([dat (cdr (syntax-e stx))] [var1 (car dat))] [var2 (cadr dat)]) ;transformer goes here ))) So I wanted a macro that will do this let binding. I've started with som...

Scheme: what are the benefits of letrec?

While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already defined function operating on arguments that remain static. An example of an old function using the defined function recurring on itself (no...

PLT Scheme Memory

So I need some help with implementing a Make-memory program using Scheme. I need two messages 'write and 'read. So it would be like (mymem 'write 34 -116) and (mymem 'read 99) right? and (define mymem (make-memory 100)).....How would I implement this in scheme? using an Alist???I need some help coding it. I have this code which makes mak...

Scheme - Memory System

I am trying to make a memory system where you input something in a slot of memory. So what I am doing is making an Alist and the car of the pairs is the memory location and the cdr is the val. I need the program to understand two messages, Read and Write. Read just displaying the memory location selected and the val that is assigned to t...

Is there a good tutorial on writing a custom language module for PLT Scheme?

Where should I start to write a custom language for PLT? Is there any information on the net (or maybe information in the manual I'm overseeing?) Or are the existing language packs the best reference for such a task? Thank you in advance! ...