scheme

Scheme: Why is there the need to use a cond here?

I tried to write a (simple, i.e. without eqan?) one? function like such: (define one? (lambda (n) ((= 1 n)))) But the above doesn't work though because when I call it like such: (one? 1) I get greeted with this error: procedure application: expected procedure, given: #t (no arguments) The correct way (from The Little Sch...

Using delay/force to implement control structures in the absence of macros?

Using Scheme the programming language, how would one use delay/force to implement control structures without resorting to using macro facilities? Thank you. ...

Why does this script-fu not work?

(define (script-fu-create-camo image colA colB)) (script-fu-register "script-fu-create-camo" "Camoflauge" "Creates a camoflauge pattern on an image" "Jeffrey Aylesworth <jeffrey@aylesworth" "Copyright (c) 2009 Jeffrey Aylesworth" "2009/12/31" "" SF-IMAGE "Image" 0 SF-COLOR "Colour 1" '(50 0 0) SF...

Debugging a Scheme program

I am using Festival, a text-to-speech synthesizer, for a project. It has a Scheme scripting language. I'm very new to scheme and hope someone can help. I just want to see the current configuration parameters of Festival. I have a Scheme prompt and can change existing parameters with the following commands: festival> (Parameter.set ...

how many elements on list with scheme

i need to write a function which calculates how many elements on list with scheme language. for example (howMany 'a) returns 0 (howMany '(a b)) returns 1 (howMany '(a (b c))) returns 2 how can i do that? i did not want a working code, just only an idea for do that. so maybe you should consider to remove working codes. :) thank you ...

How to combine two generators in a non-trivial way.

Hi, I have a generator which produces all positive integers that are powers of 2, and another which produces all integers that are powers of 3. I now need to use those to produce integers of the form 2^i*3^j where i,j >=0,0 in the increasing order. The point of using generators is to reduce memory consumption, I think. I have been tryin...

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

Why C is the language of compilers- when a Scheme subset would seem to be a better fit?

I was just listening to episode 57 of Software Engineering Radio (TRANSCRIPT: http://www.se-radio.net/transcript-57-compiletime-metaprogramming ) I'm only 40 minutes in, but I'm wondering why C is the language of compilers- when a Scheme subset would seem to be a better fit? (or some other HLL) (excluding the obvious reason of not wanti...

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

Hackable scheme implementation with decent C++ FFI

I have tried: scheme48, chicken, gambit, clojure. I am looking for a scheme implementation that's readable (the implementation itself), and has a decent C++ ffi, and good debugging suport (so when I get an exception, I should get popped into a recursive repl). What suggestions do people have? ...

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

RAII in Scheme?

Is there anyway to implement Resource Acquisation is Initialization in Scheme? I know that RAII does not work well in GC-ed languages (since we have no idea whe the object is destroyed). However, Scheme has nice things like continuations, dynamic-wind, and closures -- is there a way to use some combination of this to implement RAII? If...

Why does "let" not evaluate, but just gives me #<promise>

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

Scheme or Common Lisp

For a school project (a free choice project), I was planning on working my way through SICP(Structure and Interpretation of Computer Programs) and learning Scheme. After that I want to create something interesting with it (also part of this project). However, from what I've read, Scheme might not be the best dialect to use for a project ...

PLT-Scheme learning reference

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