scheme

Scheme list modification

I am trying to write a scheme function that takes a list of the form: ((#f ((1 1) (2 1))) (#f ((1 3) (5 1))) (#f ((1 4) (7 1))) ) and removes all the #f to give a list like: ( ((1 1) (2 1)) ((1 3) (5 1)) ((1 4) (7 1)) ) I have tried the following code but cannot get it to work: (define meth (lambda lst (if (equal? (cdr...

Implicit currying in Scheme with syntax-rules?

Jeffrey Meunier has an implicit Curry macro here, which uses defmacro. I was wondering if someone has ever written this with syntax-rules? ...

PLT Racket test cases for multiple values.

Hello, I can't seem to test a function I wrote in PLT Racket using the test-engine/racket-tests package. The code is listed below. It returns multiple values (not sure why they don't call them tuples). (define (euclid-ext a b) (cond [(= b 0) (values a 1 0)] [else (let-values ([(d x y) (euclid-ext b (modulo a b))]) ...

Can you return a value in Scheme that won't be printed in a list?

I'm trying to return an invisible value in a scheme function, but can't seem to get anything that WONT be printed to the screen, which is what I need. Is there a value in scheme that can be added to a list which won't be printed in a (display) call? ...

Scheme instead of Applescript?

Can I use Scheme instead of Applescript on the Mac to automate apps such as iTunes, iCal, Mail, etc.? ...

What are examples of Symbolic Programming?

I have to do a term project in my symbolic programming class. But I'm not really sure what a good/legitimate project would be. Can anyone give me examples of symbolic programming? Just any generic ideas because right now I'm leaning towards a turn based fight game (jrpg style basically), but I really don't want to do a game. ...

In SICP 3.2, The Environment Model of Evaluation, is an environment initially the same as its first frame?

In The Structure and Interpretation of Computer Programs part 3.2, an "environment" is defined as "a sequence of frames." But as far as I can see, the book doesn't further discuss the difference between an environment and a frame. Also, I suspect the drawings of environments conflates them with frames because books drawings are small a...

Scheme Understanding

I am supposed to write a scheme function (digit-count n) that accepts a positive integer n and evaluates to the number of digits of n that are 6, 4, or 9. I am having trouble understanding what exactly I am supposed to do, I am confused about the "digits of n that are 6, 4 or 9", what does this mean? ...

Why isn't promise a data type in Scheme?

The object returned by delay in Scheme is "a promise", but promises are not considered to be a type (so there is no promise? procedure, and it's not listed as a type in R5RS or R6RS). Is there a strong reson why this is so? It would seem quite natural to me to do something like (if (promise? x) (force x) x), for example. (And I see that...

Scheme Code Analysis for Space vs. Time

I'm working my way through the online MIT lectures for the classic 6.001 course: The Structure and Interpretation of Computer Programs. I'm trying to gain an understanding of analyzing code complexity in terms of memory usage vs. execution time. In the first few lectures, they present a solution in Scheme for the Fibonacci Series. ...

Scheme String Help

I am trying to write a function that evaluates to the number of distinct characters in the input string str. So for example (distinct-char "eeeiicczz") would return 4. I need some help with my code. This is what I have. (define string-contains (lambda (str char) (if (equal? str "") #f (if (char=? (string-ref str 0...

problem in scheme

.............................................. ...

Scheme Editor prog

Hi, i am trying to develop an editor in Scheme (DrRacket) passing lists into the structures. I handled all the functions of an editor like the keystrokes, backspace, left and right etc but i am not getting the idea of how to implement mouse selection which highlights the selected text. Can any one of you help me with it. Thanks ...

Nesting Function Calls

Hey all, This has been driving me absolutely nuts. I have a substitute function like this: (define (mysub x bind body) ;; x, bind, body are lists ...) I need to call the function like this: ;;this is the explicit call for when length x = length bind = 2. ;;how do I generalize these nested calls? ;;in case it's not obvious, i'm ...

SICP, Scheme, DrRacket Question: Timer/profiler function?

I'm currently trying to do exercise 1.22, which needs a function called runtime that returns the number of milliseconds the system has been running. However, my environment (R5RS) does not seem to have this. It does not have time, current-milliseconds, current-inexact-milliseconds, etc, either. What function do I have access to, to pro...

Can call-with-current-continuation be implemented only with lambdas and closures?

Does anyone know if call/cc can be implemented with just lambdas and closures? It seems that call/cc interrupts the program's flow (like an exception) but lambdas and closures can't do that. Therefore I think call/cc can't be implemented via lambdas and closures. Any more ideas? ...

8-puzzle bfs scheme implementation

i was looking at implementing the bfs in scheme to solve the 8 puzzle problem, this is the code i have so far (giving some error im unable to debug):: ;;some operators for defining the strucuture (define blank 'blank) (define depth 0)(define path-cost 0) (define nw 0) (define n 1) (define ne 2) (define w 3) (define c 4) (define e 5) (d...

How to create cairo surface in guile

I have this code guile> (cairo-pdf-surface-create "foo.pdf" 100.0 100.0) ; and get this error standard input:29:1: In procedure cairo-pdf-surface-create in expression (cairo-pdf-surface-create "foo.pdf" 100.0 ...): standard input:29:1: Wrong type (expecting string): 100.0 ABORT: (wrong-type-arg) and when I use strings as width and hei...

Computing the longest common subsequence length of two strings in Scheme

I am trying to write a function which computes the length of the longest common subsequence of the two input strings str1 and str2. For example (LCS "scheme" "aheme") would return 4. I need some help getting started. Any ideas how to compute this? I am also limited to the following built in function: (read) (cond) (string-length ...

How can I use external variables in eval in Scheme?

I am trying something out in Scheme for fun. I'm trying to make an Area function that gets the type of the thing it's operating on and then calls a different function depending on the type of object. Here's my code: (define (area object) (if (not (null? (eval (word 'area- (get-type object))))) (eval (list (word 'area- (get-typ...