scheme

Getting the median of 3 values using scheme's

The problem this time is to get the median of three values (easy) I did this: (define (med x y z) (car(cdr(x y z))) and it was accepted but when testing it: (med 3 4 5) I get this error: Error: attempt to call a non-procedure (2 3 4) And when entering letters instead of number i get: (md x y z) Error: undefine...

Are incremental Macro definition possible?

I often find the following type of incremental definition useful: (define (foo) (display "bar")) (foo) ;prints bar (define foo (let ((bar foo)) (lambda () (display "foo") (bar)))) (foo) ;prints foobar How do I preform this type of incremental definition with macros? I could not get let-sy...

Scheme function to remove first element

write a scheme function that remove the first top level occurrence of a given item from a list of items. eg given list (a b c) item b, result list (a c) plz help me ...

Scheme open source projects?

Hi I'm learning scheme and was wondering if there are any active open-source projects I might be able to get involved in? I'm nearing the end of SICP and although this has good complex examples no textbook code compares to real-world applications. eg testing code / benchmarking / revision control styles / sheer size and scope etc. Henc...

Recursive breadth first tree traversal

I'm pulling my hair out trying to figure out how to implement breadth first tree traversal in scheme. I've done it in Java and C++. If I had code, I'd post it but I'm not sure how exactly to begin. Given the tree definition below, how to implement breadth first search using recursion? (define tree1 '( A ( B (C () ()) (D () ()) ) (E (...

Graph representation in Dr Scheme

I want to represent a graph in Dr. Scheme in the following manner: For each node I want to store it's value and a list of adjacent nodes,the problem which i'm having difficulties with is that I want the adjacent nodes to be stored as references to other nodes. For example: I want node ny to be stored as („NY“ (...

Scheme accumulative recursion with lists

How can I pass a list as a parameter to a function adding elements to it recursively,and have it unmodified when it comes out of recursion? I want to use the list at each level of recursion with the list having the values added by deeper recursion levels. To be more specific I want to do a DFS search on a graph and I want to store in t...

Scheme Depth-first search of a graph function

This is a homework question,I'm trying to do a Depth-first search function in Scheme,Here's the code I've written so far: (define explore (λ(node visited) (let* ([neighbors (force (cdr node))] [next (nextNode visited neighbors)] [is-visited (member? node visited)]) (cond ;if I ...

Continuation (call/cc) in Scheme

Hi All, I need to understand Continuations in Scheme for my upcoming exams and I have no idea about continuations at all. Can anyone please suggest me sources of how to go about learning continuations? Regards, darkie ...

How do I learn Scheme?

Hey, I'm a relative newbie to programming. I've picked up some very basic Java (File I/O, GUIs, inheritance) and would like to take a look at functional programming - in particular, I would like to learn Scheme. I'm having some trouble finding a Scheme implementation I can understand. Interpreters are weird; I'm not sure how to save my p...

Web development: Haskell or Scheme

I would like to to choose one of these languages for building web applications. I'm not interested in framework per se, but have the following needs: Rapid development. Easy to scale. Strong community for the web. Quick and easy to deploy. I'm very familiar with Haskell, and have some familiarity with scheme (in particular PLT). Sch...

parsing a list and producing a structure of that

;; structure representing homework points ;; nr: number - the number of the homework ;; points: number - the number of points reached (define-struct homework (nr points)) ;; parse-homework: (list of number pairs) -> (list of homework) ;; The procedure takes a list of number pairs and produces a list of homework structures ;; Examp...

What's the scheme name of background of the line numbers in Vim?

The bar where the line numbers are is gray in the following scheme: louver.vim I would like to change its color but can't figure out the name. " Normal hi Normal guifg=black guibg=white gui=none hi Normal ctermfg=black ctermbg=white cterm=none hi NonText guifg=darkgray guibg=white ...

Problem with circular definition in Scheme

I am currently working through SICP using Guile as my primary language for the exercises. I have found a strange behavior while implementing the exercises in chapter 3.5. I have reproduced this behavior using Guile 1.4, Guile 1.8.6 and Guile 1.8.7 on a variety of platforms and am certain it is not specific to my setup. This code works f...

What, if any, is wrong with this definition of letrec in Scheme?

R5RS gives proposed macro definitions for library forms of syntax: http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html#%_sec_7.3 Which also defines letrec, in a very complicated way, certainly not how I would define it, I would simply use: (define-syntax letrec2 (syntax-rules () ((letrec2 ((name val) ...) body bod...

Run a site on Scheme

I can't find this on Google (so maybe it doesn't exist), but I basically'd like to install something on a web server such that I can run a site on Scheme, PHP is starting to annoy me, I want to get rid off it, what I want is: Run Scheme sources towards UTF-8 output (duh) Support for SXML, SXLT et cetera, I plan to compose the damned th...

Definition of "lisp form"?

Hi, What exactly the definition of a "Lisp form"? As far as I know, it's "either an atom or a list that has a symbol as its first element". But then, this (in Scheme) would not be a form: ((lambda () 42)) ;; The answer to Life, the Universe and Everything. Because the first element of the list is itself another list. And after it'...

Racket URL dispatch

I'm trying to hook up URL dispatch with Racket (formerly PLT Scheme). I've taken a look at the tutorial and the server documentation. I can't figure out how to route requests to the same servlets. Specific example: #lang scheme (require web-server/servlet) (require web-server/dispatch) (provide/contract (start (request? . -> . respon...

Racket regular-expression matching

I'm trying to create a regex that matches the inverse of a certain string type (so, strings not ending in ".js", for example). According to the documentation, that should be the expression #rx"(?!\\.js$)", but it doesn't seem to work. To test it out, I have this function: (define (match-test regex) (map (lambda (text) (...

Are there any purely functional Schemes or Lisps?

I've played around with a few functional programming languages and really enjoy the s-expr syntax used by Lisps (Scheme in particular). I also see the advantages of working in a purely functional language. Therefore: Are there any purely functional Schemes (or Lisps in general)? ...