[Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
Dear chicken-users; I have a simple program that does most of its heavy lifting at compile time. To demonstrate the issue, I've written two stubs (as simple as I could make them but still show the issue I'm having). File number one is called ticket-stub.scm: -8 (use s (srfi 1))

Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 01:26:08PM +0100, Sandra Snan wrote: Dear chicken-users; I have a simple program that does most of its heavy lifting at compile time. To demonstrate the issue, I've written two stubs (as simple as I could make them but still show the issue I'm having). File number

Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
On Mon, 10 Mar 2014 13:54:03 +0100, Peter Bex peter@xs4all.nl wrote: On Mon, Mar 10, 2014 at 01:26:08PM +0100, Sandra Snan wrote: Dear chicken-users; I have a simple program that does most of its heavy lifting at compile time. To demonstrate the issue, I've written two stubs (as

[Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
Hello, I found a Scheme implementation of the Caesar cipher on Rosetta Code. It said This was written by a novice, please review... So I reviewed it, and basically rewrote it. I think my version is much better (clearer) but since I too am a novice, I feel bad removing the novice warning. Could

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Phil Bewig
I would use an auxiliary function char-plus to add or subtract an offset to a character: (define (caesar str n) (define (char-plus c) (let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ)) (if (not (char-alphabetic? c)) c (let ((i (- (char-integer (char-upcase c)) 65)))

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 10:26:56AM -0500, Phil Bewig wrote: I would use an auxiliary function char-plus to add or subtract an offset to a character: (define (caesar str n) (define (char-plus c) (let ((alpha ABCDEFGHIJKLMNOPQRSTUVWXYZ)) (if (not (char-alphabetic? c)) c

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Jörg F. Wittenberger
Am 10.03.2014 15:51, schrieb Daniel Carrera: Hello, I found a Scheme implementation of the Caesar cipher on Rosetta Code. It said This was written by a novice, please review... So I reviewed it, and basically rewrote it. I think my version is much better (clearer) I tend to agree that

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Phil Bewig
I used only the procedures provided by RnRS, instead of loading SRFI-13, but you could use string-map if you want to. For those who prefer to roll their own, here is a simple version of string-map! that mutates the string in place: (define (string-map! f str) (do ((i 0 (+ i 1))) ((= i

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
Thanks. I think it's fair to use SRF-13. Now that I learned some character functions from Phil, I think the following is nice and compact: (define (caesar char) (if (not (char-alphabetic? char)) char ; Return other chars verbatim. (let ((i (- (char-integer (char-upcase char)) 65)))

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread John Cowan
Daniel Carrera scripsit: (define (caesar char) (if (not (char-alphabetic? char)) char ; Return other chars verbatim. (let ((i (- (char-integer (char-upcase char)) 65))) (integer-char (+ 65 (modulo (+ i key) 26)) (print (string-map caesar msg)) This isn't i18n-safe,

Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Sandra Snan
I couldn't quite get this to work: ticket-stub.scm 8 (use s (srfi 1)) (begin-for-syntax (import chicken) (use s (srfi))) (define-syntax create-tickets (ir-macro-transformer (lambda (f i c) `(list ,@(filter-map (lambda (x) (if (s-contains? enemy-

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
On 10 March 2014 17:10, John Cowan co...@mercury.ccil.org wrote: This isn't i18n-safe, because char-alphabetic? can return #t on non-Latin letters. Convert to an integer first and make sure it's in the safe range. Then add a comment to the effect that this assumes a Scheme in which

Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Peter Bex
On Mon, Mar 10, 2014 at 07:37:36PM +0100, Sandra Snan wrote: I couldn't quite get this to work: It still can't find s-contains. If I move the entire (define-syntax create-tickets ...) sexp to the end of begin-for-syntax, it can't find create-tickets when called later. This is unfortunate: I

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Daniel Carrera
On 10 March 2014 20:04, Daniel Carrera dcarr...@gmail.com wrote: I am trying to write an R7RS-compliant version. R7RS would give me import, as well as char-integer and integer-char. The problem I'm having is that my code does not work when I compile it, or when I use csi -s, but it works

Re: [Chicken-users] Review my Caesar Cipher?

2014-03-10 Thread Alex Shinn
On Tue, Mar 11, 2014 at 6:16 AM, Daniel Carrera dcarr...@gmail.com wrote: On 10 March 2014 20:04, Daniel Carrera dcarr...@gmail.com wrote: I am trying to write an R7RS-compliant version. R7RS would give me import, as well as char-integer and integer-char. The problem I'm having is that my

Re: [Chicken-users] R7RS: (current-jiffy) and (jiffies-per-second)

2014-03-10 Thread Alex Shinn
On Sun, Mar 9, 2014 at 7:51 PM, Daniel Carrera dcarr...@gmail.com wrote: Hello, I hope nobody minds an R7RS question. This list seems to have people knowledgeable of R7RS. It seems weird that R7RS would specify the functions: There's also scheme-repo...@scheme-reports.org but I doubt people

Re: [Chicken-users] R7RS: (current-jiffy) and (jiffies-per-second)

2014-03-10 Thread John Cowan
Alex Shinn scripsit: current-jiffy could always return fixnums. Alas, only if you are in the sweet spot of: 1) programs don't run for too long 2) fixnums are sufficiently large 3) jiffies aren't too precise On a 32-bit system with microsecond resolution (which does not necessarily mean

Re: [Chicken-users] 4.8.0.5 syntax weirdness

2014-03-10 Thread Jim Ursetto
This is the fix: commit f8230a466ce3a86f360178f115fb62ee124448b9 Author: Peter Bex peter@xs4all.nl Date: Sun Jun 30 18:50:09 2013 +0200 Fix meta-evaluation to actually take place in the meta environment and add tests Signed-off-by: Christian Kellermann ck...@pestilenz.org It