scheme

Functional Programming - Implementing Scan (Prefix Sum) using Fold

Hi guys! I've been teaching myself functional programming, and I'm currently writing different higher order functions using folds. I'm stuck implementing scan (also known as prefix sum). My map implementation using fold looks like: (define (map op sequence) (fold-right (lambda (x l) (cons (op x) l)) nil sequence)) And my shot at sc...

SSAX-SXML and numbers

I'm using SSAX-SXML for working with a tree structure that just mimics the XML data encoding. So I thought of using the SXML representation directly as the data structure to work with. Everything works very well, and I get all the functionality of default accessors and XPath, which I found very useful. But I have a problem. XML represen...

homework on scheme

how to design a function content which inputs a single list of atoms lat and which returns the content of lat.Thus the content of '(a b c a b c d d) is '(a b c d). ...

how to define last in scheme?

how can I write a function to take the last element of the list? ...

"Functional programming" has a clear meaning, but does "functional language"?

I understand very clearly the difference between functional and imperative programming techniques. But there's a widespread tendency to talk of "functional languages", and this really confuses me. Of course some languages like Haskell are more hospitable to functional programming than other languages like C. But even the former does I/O...

What kind of advantages are there to changing 'cond' to be a special form

What kind of advantages are there to changing 'cond' to be a special form instead of syntactic sugar? ...

If I have: (apply f '(x1 x2 x3 .... xn)) and I'd like to change it to a Macro expansion

If I have: (apply f '(x1 x2 x3 .... xn)) and I'd like to change it to a Macro expansion: (f x1 x2 x3...xn), what kind of problems can occur? ...

Write Scheme data structures so they can be eval-d back in, or alternative

I'm writing an application (A juggling pattern animator) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will let me "explode" expressions into expressions that can still be eval'd but contain the data as literals for manual tweaking. For example, (4hss->sexp "7...

Parameter Passing in Scheme

Hi All, Can anyone help me out understanding the various parameter passing modes in Scheme? I know Scheme implements parameter passing by value. But how about other modes? Is there any good documentation for parameter passing in Scheme? ...

What implementation of Scheme would you recommend to learn the language?

I am going to read the classic "Structure and Interpretation of Computer Programs" link text and it utilizes the Scheme language to teach its material. Does any one have advice about what Scheme would be easy to use (on Windows) and complete? Thanks! ...

What's wrong with my Scheme compiler?

I'm wondering why nested function calls don't work. I'm implementing Dybvig's Heap-based model from his paper http://www.cs.indiana.edu/~dyb/pubs/3imp.pdf Chapter 3. I'm doing it in JavaScript. Source is here: http://github.com/z5h/zb-lisp Pretty much everything is in parser.js right now. To run, load test.html in Firefox with Fireb...

double in scheme

How to write a program in scheme that takes an arbitrary sexpression consisting of integers and which returns an sexpression that is identical to the original but with all the integers doubled? ...

Bounded variables and scope

Hi all, I´v tried to write a procedure that gets an integer as parameter and returns true if the number is a palindrome and false otherwise and it seems to be that there is a problem with changing a global parameter's value whithin an internal function block. (define index 0) (define (palindrome? x) (if (= (lenght x) 1) #t ...

(fluxus) learning curve

I'm trying to have some fun with fluxus, but its manual and online docs all seem to assume that the reader is already an expert network programmer who's never heard of Scheme before. Consequently, you get passages that try to explain the very basics of prefix notation, but assume that you know how to pipe sound-card data into the program...

Tower of hanoi, python -> scheme, shows error. What am I missing ?

The python implementation import sys def move(src, dst, tmp, num): if num == 1: print 'Move from', src, 'to', dst else: move(src, tmp, dst, num-1) move(src, dst, tmp, 1) move(tmp, dst, src, num-1) move('left', 'right', 'middle', int(sys.argv[1])) Gives the right solution for tower of hanoi. But my sch...

No idea how to solve this SICP exercise

This is not homework. Exercise 1.11: A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure that computes f by means of an iterative process. Implementing it recursively is simple enough. Bu...

Matrix addition in Scheme

I am trying to add a matrix and it is not working... (define (matrix-matrix-add a b) (map (lambda (row) (row-matrix-add row b)) a)) (define (row-matrix-add row matrix) (if (null? (car matrix)) '() (cons (add-m row (map car matrix)) (row-matrix-add row (map cdr matrix))))) (define (add-m row col) (...

Scheme: Detecting duplicate elements in a list

Does R6RS or Chez Scheme v7.9.4 have a library function to check if a list contains duplicate elements? Alternatively, do either have any built in functionality for sets (which dis-allow duplicate elements)? So far, I've only been able to find an example here. The problem with that is that it doesn't appear to actually be part of the ...

Scheme and let syntax

(define (Integral f a b N) ;define h as a constant (let((h (/ (- b a) N)))) (define (Term n) (* (/ h 3) (+ (* 2 (f (+ a (* 2 (* n h))))) (* 4 (f (+ a (* 2 (* (- n 1) h))))) ) )) (+ (* (/ h 3) (+ (f a) (f b))) (sum Term a next (/ N 2.0)))) This code produces an...

Scheme implementations - what does it mean?

Hi, I'm a beginning student in CS, and my classes are mostly in Java. I'm currently going through "Little Schemer" as a self study, and in the process of finding out how to do that I have found numerous references to "implementations" of Scheme. My question is, what are implementations? Are they sub-dialects of Scheme, or is that som...