scheme

Binding function name as argument inside of macro

So I'm playing around with a simple doc-string system as a warmup in scheme, the idea being you could do something like: (def-with-doc (foo a b) (desc "Takes two parameters and sums them") (param 'a "First parameter") (param 'b "Second parameter") (return "Sum of arguments") (+ a b) Which would be turned into: (begin ...

Identifiers and Binding in Scheme - how to interpret the function ?

Hi ! I am reading DrRacket document http://docs.racket-lang.org/guide/binding.html There is a function (define f (lambda (append) (define cons (append "ugly" "confusing")) (let ([append 'this-was]) (list append cons)))) > (f list) '(this-was ("ugly" "confusing")) I see that we define function f, inside ...

In what order does Scheme code run?

We've been taught various syntax and told how to write definitions, but we've never written any code an ran it. What is the order that Scheme code runs in? Thanks! ...

Replace an element in a list in Scheme

Hi, I'm looking for a function in Scheme to replace a element in an equation by a value. Exemple : '(+ a b c a) with (1 2 3) should give me '(+ 1 2 3 1). (I don't want to resolve the equation, it was just an exemple) Basically, I want to say that a=1, b=2, c=3 To proceed, I extract the variables of my first list in another list. The...

Searching through lists with Scheme (DrRacket)

So here's my code: (define *graph* (read(open-input-file "starbucks4.sxml"))) (define get-artifacts (lambda (l) (member (list 'opm:artifact) l))) When I type get-artifacts(*graph*) I get an error saying procedure application: expected procedure, given:...(the whole of my file contents) Anyone see what I'm doing wrong? Thanks gu...

Using the member function in Scheme

This is my code: (define p (read(open-input-file "starbucks4.sxml"))) (define get-artifacts (lambda (l) (member (list 'opm:artifact) l))) (get-artifacts p) I was told that the member function searches completely throughout a list. In the .sxml document there is a complicated list that has many elements called "opm:artifa...

go through an sxml file in schme

im trying to load a sxml file... i manage to do that in scheme. now i want to go through it using recursion and located items that i want. my code is like this, (define file (read(open-input-file "test1.sxml"))) (define myfunc (lambda (S) (if (eq? "foo" (car S)) (display "found\n") (display "not found\n") ) ...

Scheme Pair's help

How can you go from (5 . 2) to (5 2) ?? ...

Scheme Logical Operators

I have a conditional and I want to test to see if two things are true. How can I do an equivalent of && or || from java in scheme? ...

Scheme Help. Structs Lists and Recursion

(define-struct binding ( let ; a string num ; a number ) ) (define Bind-A (make-binding empty 1)) (define Bind-B (make-binding "A" 2)) (define Bind-C (make-binding "F" 1)) (define Bind-D (make-binding "A" 1)) (define Bind-E (make-binding "C" 1)) (define Bind-F (make-binding "E" 3)) (define Bind-All (list Bind-A Bind-B Bind-...

Compiling with Bigloo

I've written a scheme file in DrRacket/Scheme and I have my .rkt file. I need to now compile what I've written with Bigloo. I have Bigloo installed, but I'm not sure how to use it. Anyone know how? ...

Scheme List Derangement (Rearrangement of sorts)

im trying to write a function in Scheme where i accept a list and return all the different derangements (look below for definition) as a list of lists derangement: A list where no item is in the same place as the original list ex: '(a b c) -> '(cab) any help is appreciated! ...

Scheme - Problems with Sorting

So I'm learning Scheme in a class and my professor doesn't answer questions after 8:00, so I'm hoping you all can help me out. Basically I have a family tree type thing and I'm trying to get all the ancestors of one person, and display them as one string, sorted alphabetically. The problem is, because of the recursion, each generatio...