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...
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)
(...
I am trying to write a macro that defines a special class of data structure with associated functions.
I know this is possible; it is done multiple times in the core language itself.
As a specific example, how would I define the define-struct macro in Scheme itself. It needs to create make-struct, struct-<<field>>, etc functions.
I tr...
I'm trying to create a binding to libpython using scheme's FFI. To do this, I have to get the location of python, create the ffi-lib, and then create functions from it. So for instance I could do this:
(module pyscheme scheme
(require foreign)
(unsafe!)
(define (link-python [lib "/usr/lib/libpython2.6.so"])
(ffi-lib lib))
...
I want to see if I can map PLT Scheme structure fields to columns in a DB.
I've figured out how to extract accessor functions from structures in PLT scheme using the fourth return value of:
(struct-type-info)
However the returned procedure indexes into the struct using an integer. Is there some way that I can find out what the fi...
How can I use arrays in scheme?
In particular, I'm attempting to implement a recursive fibonacci procedure using memoization. Do arrays even exist in scheme?
If not, how can I implement memoization?
...
Let's say I have a procedure foo that takes three arguments, and returns a list of them all doubled:
(define (foo a b c)
(list (* 2 a ) (* 2 b) (* 2 c)))
What I'd like to be able to do is create another procedure which accepts a list, and calls foo using the list elements as arguments, like this:
(define (fooInterface myList)
.....
I earlier asked a question about arrays in scheme (turns out they're called vectors but are basically otherwise the same as you'd expect).
Is there an easy way to do multidimensional arrays vectors in PLT Scheme though? For my purposes I'd like to have a procedure called make-multid-vector or something.
By the way if this doesn't alrea...
I will use a simple example to illustrate my question. In Java, C, or any other OOP language, I could create a pie class in a way similar to this:
class Apple{
public String flavor;
public int pieces;
private int tastiness;
public goodness(){
return tastiness*pieces;
}
}
What's the best way to do that with ...
When I wrote best I meant:
Speed,
Have an IDE, a debugger,
Compiling to machine code or some other language,
Quality of implementation and,
Completeness.
...
For example, take a look at this code (from tspl4):
(define proc1
(lambda (x y)
(proc2 y x)))
If I run this as my program in scheme...
#!r6rs
(import (rnrs))
(define proc1
(lambda (x y)
(proc2 y x)))
I get this error:
expand: unbound identifier in module in: proc2
...This code works fine though:
#!r6rs
(import (rnr...
I'm kinda confused.....
(define m (list 1 2 3 '(5 8)))
(let ((l (cdr m)))
(set! l '(28 88))) ==>(1 2 3 (5 8))
(define o (list 1 2 3 '(5 8)))
(let ((l (cdr o)))
(set-car! l '(28 88))) ==> (1 (28 88) 3 (5 8))
Why does (set! l '(28 88))) not update m?
...
Given a tree, I want to find the paths from the root to each leaf.
So, for this tree:
D
/
B
/ \
A E
\
C-F-G
has the following paths from root (A) to leaves (D, E, G):
(A B D), (A B E), (A C F G)
If I represent the tree above as (A (B D E) (C (F G))) then the function g does the trick:
(define (paths tree)
(cond ...
I've started learning Scheme, for fun mostly, and because I've never used a functional language before. I chose Scheme because I wanted to read SICP for a long time.
Anyway, I'm currently learning about lists, and before that I learned about cons, car and cdr. And there's an example that creates a list of lists with cons, like this :
...
I am having some trouble understanding the behavior of the following
Scheme program:
(define c
(dynamic-wind
(lambda () (display 'IN)(newline))
(lambda () (call/cc (lambda (k)
(display 'X)(newline)
k)))
(lambda () (display 'OUT)(newline))))
As I understand, c will be bound to th...
I'm new to Scheme -- the functional programming language and I like it a lot for its first-class/higher-order functions. However, my data comes from a COM source with an object-oriented API.
I know Scheme and COM belong to different programming paradigms, but I'm wondering if there is any interface or a way for Scheme to connect to a C...
I have read McCarthy's 1960 paper on LISP and found no reference to anything that's similar to user-defined macros or normal order evaluation. I was wondering when marcos first appeared in programming language history (and also in Lisp history):
When was the idea of user-defined code transformation (before interpretation or compilation...
I want to match one of the following two lists in Racket (formerly PLT Scheme):
'(somename : (_ptr o sometype))
or
'(somename : (_ptr io sometype))
As you can see, the only difference is the literals 'o and 'io in the embedded list.
I can see two basic ways to do this.
Either:
(match myexpr
[(list name ': (list '_ptr 'o _)) ...
Hi All,
For the 1st example given on site: View-Site, my understanding is that normal order evaluates to [6;1;1] and applicative order evaluates to [6;2;2]
Can anyone please confirm my assessment?
Regards,
darkie
...
Is there a built-in way to get at POST/GET parameters in Racket? extract-binding and friends do what I want, but there's a dire note attached about potential security risks related to file uploads which concludes
Therefore, we recommend against their
use, but they are provided for
compatibility with old code.
The best I can fi...