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

[Chicken-users] Problem with (fold)

2014-03-11 Thread Daniel Carrera
Hello, I'm having a problem with (fold): (use srfi-1) ; List library. (fold (lambda (a b) (+ (* a 10) b)) 0 '(1 2 3)) I was expecting this to return 123, but it returns 60. I'm confused. In my mind, at each step I shift the current value to the left (i.e. multiply by 10) and add the new

Re: [Chicken-users] Problem with (fold)

2014-03-11 Thread Daniel Carrera
I think I've answered my own question: I have to switch the a and the b. I guess I was confused as to how parameters are sent into the lambda. Cheers, Daniel. On 11 March 2014 15:30, Daniel Carrera dcarr...@gmail.com wrote: Hello, I'm having a problem with (fold): (use srfi-1) ; List

Re: [Chicken-users] Problem with (fold)

2014-03-11 Thread Daniel Carrera
On 11 March 2014 15:41, Peter Bex peter@xs4all.nl wrote: To avoid such mistakes, it's helpful to use mnemonic names: (fold (lambda (item result) (+ (* result 10) item)) 0 '(1 2 3)) Thanks. I was mentally reading from left to right, so I ended up assuming that it was (result item).

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

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

2014-03-09 Thread Daniel Carrera
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: (current-jiffy) -- An exact integer representing the number of jiffies (arbitrary unit of time) since some arbitrary epoch.

[Chicken-users] Module naming conventions in R7RS

2014-03-08 Thread Daniel Carrera
Hello, The R7RS-small spec does not seem to suggest a naming convention for modules. It merely says that module name is a list of identifies. I take that to mean that the following are equally valid: (import (srfi/17)) (import (srfi 17)) (import (srfi schemers org 17)) (import (org schemers srfi

Re: [Chicken-users] Module naming conventions in R7RS

2014-03-08 Thread Daniel Carrera
) there are various ways to refer to the srfis: (srfi-17) (srfi :17) etc. At this point, they all support (srfi 17), so I've been using that. I don't really care which form is standard, but I'm excited about reducing use of cond-expand in imports. -seth On 03/08/2014 08:06 AM, Daniel Carrera wrote

[Chicken-users] Question about booleans

2014-03-07 Thread Daniel Carrera
Hello, I have a problem with and: #;2 (use srfi-1) #;3 (fold-right and #t '(#t #t #t #t)) Error: unbound variable: and #;4 and Error: unbound variable: and #;5 (and #t #t) #t I'm confused. Is and defined as a macro? If so, why? My feeling is that I should be able to use and inside a fold.

Re: [Chicken-users] Question about booleans

2014-03-07 Thread Daniel Carrera
On 7 March 2014 15:29, Peter Bex peter@xs4all.nl wrote: On Fri, Mar 07, 2014 at 02:42:00PM +0100, Daniel Carrera wrote: I'm confused. Is and defined as a macro? If so, why? Yes, because it needs to be short-cutting evaluation when it hits the first #f. Otherwise (and #f (error foo

[Chicken-users] Question about the implementation of list?

2014-03-07 Thread Daniel Carrera
Hello, I recently learned that a list is defined as either the empty list or a pair where the second element is a list. For example: #;2 (list? (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 '())) #t #;3 (list? (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 6)) #f Does this mean that list? is O(n)

[Chicken-users] Question about set-car! and set-cdr!

2014-03-06 Thread Daniel Carrera
Hello, I have recently learned about set-car! and set-cdr! which eventually led me to learn about how Racket removed them years ago for the reasons given in this post: http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-set-cdr.html On the other hand, Chicken certainly has set-car!

Re: [Chicken-users] Question about set-car! and set-cdr!

2014-03-06 Thread Daniel Carrera
On 6 March 2014 14:37, Jörg F. Wittenberger joerg.wittenber...@softeyes.net wrote: Am 06.03.2014 09:05, schrieb Daniel Carrera: I have recently learned about set-car! and set-cdr! which eventually led me to learn about how Racket removed them years ago for the reasons given in this post

Re: [Chicken-users] Question about set-car! and set-cdr!

2014-03-06 Thread Daniel Carrera
On 6 March 2014 20:04, John Cowan co...@mercury.ccil.org wrote: Ivan Shmakov scripsit: Maybe this could be addressed by splitting the scheme module of chicken into a scheme-pure for the sake of safety, scheme-mutations having the rest and make scheme importing and reexporting

[Chicken-users] Why is it called Chicken?

2014-03-04 Thread Daniel Carrera
Perhaps a silly question, but I'm curious. Why is Chicken Scheme called Chicken? Cheers, Daniel. -- When an engineer says that something can't be done, it's a code phrase that means it's not fun to do. ___ Chicken-users mailing list

Re: [Chicken-users] Why is it called Chicken?

2014-03-04 Thread Daniel Carrera
. On Tue, Mar 4, 2014 at 3:22 PM, Daniel Carrera dcarr...@gmail.com wrote: Perhaps a silly question, but I'm curious. Why is Chicken Scheme called Chicken? Cheers, Daniel. -- When an engineer says that something can't be done, it's a code phrase that means it's not fun to do

Re: [Chicken-users] Problems with the dollar egg.

2014-03-03 Thread Daniel Carrera
On 3 March 2014 17:57, Alaric Snell-Pym ala...@snell-pym.org.uk wrote: Python does not work in the Chicken interpreter either. :-) (Though in principle one could write a Python egg using the Python/C API.) There's slightly more to it than this, however. The FFI only works in compiled

[Chicken-users] Problems with the dollar egg.

2014-03-02 Thread Daniel Carrera
Hello, I installed Chicken for the first time last night and today I'm starting to play with it. I installed the dollar egg and I'm having some trouble: http://wiki.call-cc.org/eggref/4/dollar I tried the example on that page, and this is what I got: --//-- #;1 ($

[Chicken-users] Question about (use numbers)

2014-03-02 Thread Daniel Carrera
Hello, I have installed the numbers egg. When I run (use numbers) I get a lot of warnings to the effect of: Note: re-importing already imported identifier: + Note: re-importing already imported identifier: - Note: re-importing already imported identifier: * Note: re-importing already imported

Re: [Chicken-users] Question about (use numbers)

2014-03-02 Thread Daniel Carrera
On 2 March 2014 17:00, Matt Gushee m...@gushee.net wrote: Does this mean that I am loading the module wrong? No. The numbers egg redefines all the standard arithmetic 'operators' (quotes because, as you are probably aware, they are really functions that just happen to be represented with

Re: [Chicken-users] Problems with the dollar egg.

2014-03-02 Thread Daniel Carrera
On 2 March 2014 17:34, John Cowan co...@mercury.ccil.org wrote: Daniel Carrera scripsit: Error: unbound variable: foreign-lambda* The Chicken FFI does not work in the interpreter. Ok. :-( Does that apply to other languages like Python? I have installed the numbers egg. When I run

Re: [Chicken-users] Problems with the dollar egg.

2014-03-02 Thread Daniel Carrera
On 2 March 2014 18:27, John Cowan co...@mercury.ccil.org wrote: Chicken is primarily a compiled Scheme: the interpreter is slow and inefficient, and provided mostly for testing, debugging, and simple scripting. If you are interested in interpreter-based Schemes exclusively, I recommend