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

2014-03-18 Thread Claude Marinier
Bonjour, Just for fun, I tried running the current Rosetta code with the TinyScheme interpreter. It has case-insensitive symbols, so it failed interestingly. The solution is to change the variable names (because otherwise 'A' is the same as 'a'). The Scheme FAQ (

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

2014-03-18 Thread John Cowan
Claude Marinier scripsit: The Scheme FAQ ( http://community.schemewiki.org/?scheme-faq-language ) states that this is defined in R5RS. Chicken is case-sensitive. Is this commonly ignored? Very commonly, but not universally so. Case-sensitivity is required in R6RS and R7RS. See

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

2014-03-13 Thread Daniel Carrera
On 12 March 2014 17:16, Alex Shinn alexsh...@gmail.com wrote: Then change your cond-expand to: (cond-expand ((or chicken gauche) ; compatibility (use srfi-13)) (else ; R7RS (import (scheme base) (scheme write That works. Thanks! I have updated the page on

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

2014-03-12 Thread Alex Shinn
On Tue, Mar 11, 2014 at 9:20 PM, Daniel Carrera dcarr...@gmail.com wrote: On 11 March 2014 12:41, Alex Shinn alexsh...@gmail.com wrote: Chibi has string-map in (chibi string). But actually, if you're aiming for R7RS support then string-map is in (scheme base). Just replace the

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

2014-03-11 Thread Daniel Carrera
With the last suggestion from Alex, and a tip to use cond-expand from Kon, I have settled on the following: - ; ; Works with Chicken Scheme and Gauche. ; (cond-expand (chicken (use srfi-13)) (gauche (use srfi-13))) (define msg The quick brown fox jumps

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

2014-03-11 Thread Alex Shinn
On Tue, Mar 11, 2014 at 7:15 PM, Daniel Carrera dcarr...@gmail.com wrote: With the last suggestion from Alex, and a tip to use cond-expand from Kon, I have settled on the following: - ; ; Works with Chicken Scheme and Gauche. ; (cond-expand (chicken (use

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

2014-03-11 Thread Daniel Carrera
On 11 March 2014 12:41, Alex Shinn alexsh...@gmail.com wrote: Chibi has string-map in (chibi string). But actually, if you're aiming for R7RS support then string-map is in (scheme base). Just replace the cond-expand with: (import (scheme base)) Hmm... sadly, (import (scheme base)) fails

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

2014-03-11 Thread Shiro Kawai
(Sorry for off-topic of ML) From: Daniel Carrera dcarr...@gmail.com Subject: Re: [Chicken-users] Review my Caesar Cipher? Date: Tue, 11 Mar 2014 13:20:15 +0100 Hmm... sadly, (import (scheme base)) fails with Chicken and Gauche. Development head of Gauche already supports r7rs, FYI. --shiro

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

2014-03-11 Thread John Cowan
Shiro Kawai scripsit: Development head of Gauche already supports r7rs, FYI. Excellent news! -- John Cowan co...@ccil.orghttp://ccil.org/~cowan No man is an island, entire of itself; every man is a piece of the continent, a part of the main. If a clod be washed away by the sea, Europe

[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] 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] 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