racket

Intuitive motivation for Literate Programming?

So, I used the scribble/lp module to write my first literate program using plt-scheme: #lang scribble/lp (require scribble/lp) <<lp_scheme.ss>> @chunk[<squarefunction> (define (f x) (* x x))] Nothing useful there, of course. Now I am sort of wondering why would I just not use plain comments, instead of literate prog...

Debugging Scheme in Emacs

I am shifting from DrScheme to Emacs to edit my PLT Scheme files. Can you teach me how to use steppers or debuggers in Emacs? Thanks. ...

Undefined function in DrScheme?

Hey i'm just trying to write some code in DrScheme: ((function (x) (* x x)) 2) but i got a message saying: reference to undefined identifier: function I'm using language "Essentials of Programming languages (3rd ed.)" and the version of DrScheme is 4.2.1 Thanks! ...

Scheme equivalent to Haskell where clause

I am just learning scheme, but I would love to be able to repeat myself less. Is there a way I can assign a name to a subexpression in the local scope? As per the comment: Haskell where clause x = s * t where s = 10 t = 20 x should be 200 in this case. ...

do any one use Dr scheme programming? how to sort using list?

which data structure to use to sort n numbers in dr scheme i m not allowed to use vector and structure ..if i use list i cant edit the list values .so how can i sort n numbers . the language i use is textual mzscheme rsr5 ...

How does PLTScheme Catch errors?

I am amazed by the "error" function in PLTScheme. If I have a division by zero, it doesnt do any other recursion and just comes out of the call stack and give me an error. Is there an implicit continuation before all the functions? Does the error throw away the call stack? Does anybody have any idea about this? ...

Scheme regular expression match

Is there a simpler way of writing in scheme (eqv? (regexp-match "0x" "0x1234") #t) #f (eqv? (regexp-match "0x" "1234") #f) #t ...

Detecting EOF in a Binary File using Scheme

(define (read-all-input) (local ((define line (bytes->list (read-bytes 4)))) (if (eof-object? line) empty (cons line (read-all-input))))) (void (read-all-input)) The above code fails because bytes->list expects an argument of type byte string, but is given # ...

Good Revision Control For PLT Scheme

Hello, Now I'm following one more friend and now I started to learn PLT Scheme(using DrScheme), but I and my friends normally help each other in some projects, to do this we use revision controllers(normally SVN, in sometimes we use git), but which is the best revision control to use with PLT Scheme? Thanks. ...

How To Build a DrScheme Teach Pack

Hello, I'm learning PLT Scheme and I want to know how can I build a Teach Pack for DrScheme, some tutorials...? Thanks. ...

PLT Scheme noob: Boolean and/or aren't procedures?

I'm trying to make a truth-table generator for a digital electronics course because that's how I have fun in my spare time and don't judge me. Anywho, I figured I'd have a hash with the string equivalent of operators as keys, and the Scheme procedures that correspond to those operators as values. E.g. (define operator-table #hash(("...

Why do you have to cons with a null to get a proper list in scheme?

I realize this is a total n00b question, but I'm curious and I thought I might get a better explanation here than anywhere else. Here's a list (I'm using Dr. Scheme) > (list 1 2 3) (1 2 3) Which I think is just sugar for this: > (cons 1 (cons 2 (cons 3 null))) (1 2 3) This, on the other hand, does something else: > (cons 1 (cons ...

Calling mysql_real_escape_string using the PLT-Scheme Foreign Function Interface

Hi, using the PLT-Scheme-FFI, I want to call the C-function unsigned long mysql_real_escape_string(MYSQL *con, char *to, const char *from, unsigned long length) from a scheme procedure and continue using the resulting string 'to' inside the caller. The call of the scheme procedure would go like this: (define-values (to) (escape-str...

Compiling a .ss file

I heard that you can compile .ss files with DrScheme, and even remember doing it once to result in some good speedups on my code, since it doesn't need to put in all the debugging info necessary for the GUI. How does one go about doing this? ...

Flush stdout in DrScheme?

I can do it in Java, Python, Haskell... how do you do it in DrScheme? A customary google search didn't yield the answer. ...

File I/O In DrScheme

(read) takes in a string from stdin, parses it as an s-expression, and returns that expression. How do I do the exact same thing, except taking input from a file? ...

Read in command line arguments from DrScheme

How do I detect what command line arguments where given when a script is run with mred? That is, the equivalent of sys.argv in Python, args[] in Java, etc... ...

Why String is not a String when it is passed to C from Scheme?

From the Plt-Scheme installation I have an example of C/Scheme interaction. There are two files: curses.c and curses-demo.ss. These files are available here. I've compiled curses.c, and trying to run curses-demo.ss And I am getting the following error: "put: expects argument of type 'character, string, or byte string'; given "Hello Worl...

"for each" or "every" keywords in Scheme

Is there a for loop or for each loop in Scheme ? I've been searching around and found there is a keyword "every" but the scheme compiler language I'm using does not have this function pre-build in. This is what it suppose to do, it can be find here (define (first-letters sent) (every first sent)) > (first-letters '(here comes the su...

Scheme, getting the pointer from pointed struct

Assume I have a such struct: (define-struct node (value next)) ;and making 2 nodes, parent pointing to child as next. (define child (make-node 2 null)) (define parent (make-node 1 child)) Under PLT Scheme, while having child in my hand (and not knowing that parent is the pointer), is it possible to find the pointing node sctuct with...