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!...
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?
...
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))
...
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?
...
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...
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...
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...
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?
...
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)
. ....
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.
...
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...
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 (>...
(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...
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...
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...
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...
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...
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!
...
Something simple as this:
Welcome to DrScheme, version 4.2.3 [3m].
Language: Lazy Scheme; memory limit: 128 megabytes.
> (let ((x 2) (y 10))
(+ x y))
#<promise>
>
I press enter for the let expression, and it gives me the #<promise>. What am I doing wrong?
...
After having got through the two Schemer books, I'm about to embark on HtDP but also discovered the http://docs.plt-scheme.org/guide material.
The previously mentioned books are more particular to Scheme, it seems, and the latter being more geared towards PLT specific extensions (modules, require, bracket syntax, etc...). The online man...