Re: [Chicken-users] build on Windows with cygwin

2007-11-20 Thread Terrence Brannon
On Nov 20, 2007 2:12 AM, felix winkelmann [EMAIL PROTECTED] wrote:
 On Nov 20, 2007 4:06 AM, Terrence Brannon [EMAIL PROTECTED] wrote:

   Is there anybody who can send me a build log for a full
   dynamic build?
 
  Do you mean like this -
  http://www.metaperl.com/tmp/chicken-cygwin-compile-transcript
 

 No, a build log for a 2.6 chicken, using the old build system.

Ok, I got 2.637. the README says
 See INSTALL for generic instructions  but there is no INSTALL file
in the distro - just INSTALL-Cmake.txt

so I did the usual ./configure  make
and got the error

.libs/libchicken_la-runtime.o:runtime.c:(.text+0xfa3b): undefined
reference to `__C_do_apply_hack'

as shown in the build log - http://www.metaperl.com/tmp/chicken-2.637-build.log


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] build on Windows with cygwin

2007-11-19 Thread Terrence Brannon
On Oct 2, 2007 1:41 AM, felix winkelmann [EMAIL PROTECTED] wrote:
 Hi, Shawn!


 The problem is that I don't know how to link dlls properly.
 The build log you've sent me only generated the static
 libs, due to a missing libdl.so (dll, or whatever).

 I need to see the exact build steps for a full build with
 dynamic linking. The shared lib generation options for
 cygwin where more or less guessed.

 Is there anybody who can send me a build log for a full
 dynamic build?

Do you mean like this -
http://www.metaperl.com/tmp/chicken-cygwin-compile-transcript


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Chicken 2.732 on Cygwin : chicken.o:chicken.c:(.text+0x9): undefined reference to `__imp__C_temporary_stack'

2007-11-16 Thread Terrence Brannon
Hi, I was having problems with the optional function in chicken 2.6 so
I got the latest official release but am having problems building it
on Cygwin. The entire compile transcript is here :

http://www.metaperl.com/tmp/chicken-cygwin-compile-transcript


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Chase's Sequence updates by Mario

2007-11-16 Thread Terrence Brannon
1 - Mario fixed the code for Chase's Sequence -
http://galinha.ucpel.tche.br:8080/Chase%20Sequence -
so that it compiles - http://paste.lisp.org/display/50948#1

It had some parenthesis issues. Probably best to update the wiki with
the fixed version.

2 - Could some typical usage examples of this be added?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] foreign-lambda - how to declare double array as argument and how to pass things to it?

2007-11-12 Thread Terrence Brannon
Well, no here is what I did:
 (let ([vec (vector 0 1 1)]) (polevl 42 vec (vector-length vec)))

how would I pass in an f64 vec?

and was I right in choosing f64vec on the chicken side for a C
function with this signature:
double polevl( x, coef, N )
double x;
double coef[];
int N;
{
 ...
}

On Nov 11, 2007 10:37 PM, Zbigniew [EMAIL PROTECTED] wrote:
 Did you try passing in an f64vector instead of a vector?


 On 11/11/07, Terrence Brannon [EMAIL PROTECTED] wrote:
  My guess was f64vector. That compiled, but passing a Scheme vector in 
  failed:
 
  #;2 (let ([vec (vector 0 1 1)]) (polevl 42 vec (vector-length vec)))
  Error: bad argument type - not a number-vector or not of the correct type
  #(0 1 1)
  f64vector



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] gettings roots (and multiplier) of a polynomial equation and vice versa + Gnu Scientific Library

2007-11-11 Thread Terrence Brannon
I'm wondering if I overlooked an egg that can do this:

1 - given the (real) coefficients of all terms of a polynomial
equation, it returns the roots and multiplier representation of it:

For example, the polynomial 2x + 2x^2 factors down to 2 * (x-(-1))(x-0),
so the multiplier is 2 and the roots are 0 and -1

2 - also, as vice versa, given the multiplier and roots, I would like
to be able to generate the real coefficents

so, given 2 as multiiplier and 0 and -1 as roots, I would like to get

0 2 2 back since the polynomial is 0*1 + 2*x + 2*(x^2)


Note:
I ran into Jown Cowan's Q language interface, but would prefer
something with fewer external requirements.

No one has an interface to the Gnu Scientific Library in the works
right? If so, that would do the trick.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] chicken.wiki.br - an anti-IE site

2007-11-11 Thread Terrence Brannon
If you visit chicken.wiki.br -
http://chicken.wiki.br/Accessing%20external%20objects

with IE or an IE-compatible browser, all the code samples do not
render, but instead put up scrollable boxes with small windows.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Fwd: gettings roots (and multiplier) of a polynomial equation and vice versa + Gnu Scientific Library

2007-11-11 Thread Terrence Brannon
Jens wrote some code for this in case there is nothing in Chicken for
it at the moment.

Only thing is doesnt do is return the multiplier for the factorization.

-- Forwarded message --
From: Jens Axel Søgaard [EMAIL PROTECTED]
Date: Nov 11, 2007 6:44 PM
Subject: Re: gettings roots (and multiplier) of a polynomial
equation and vice versa + Gnu Scientific Library
To: Terrence Brannon [EMAIL PROTECTED]


[Feel free to forward this to the Chicken mailing list
(I would myself if I were subscribed)]

Terrence Brannon wrote:
 I'm wondering if I overlooked an egg that can do this:

 1 - given the (real) coefficients of all terms of a polynomial
 equation, it returns the roots and multiplier representation of it:

 For example, the polynomial 2x + 2x^2 factors down to 2 * (x-(-1))(x-0),
 so the multiplier is 2 and the roots are 0 and -1

Here is an implementation of a method from Numerical Recipes in C:

Your example is solved like this:

   (roots '(0.0 2.0 2.0))
  (-1.0 0.0)

Numerical code is tricky, so I wrote a literal translation.
It ain't pretty, but it works.


/Jens Axel Søgaard


; roots : (list numbers) - (list numbers)
;   return list of roots of the polynomial with
;   coeffecients from the argument list, lowest degree first
(define (roots coeffs)
  (let* ([degree (- (length coeffs) 1)]
 [roots  (make-vector degree 0.0)])
(polynomial-roots-all (list-vector coeffs) degree roots)
(sort (vector-list roots)
  (lambda (x y)
(or ( (real-part x) (real-part y))
(and (= (real-part x) (real-part y))
 ( (imag-part x) (imag-part y



(define (polynomial-roots-laguerre a m x)
  ; Given the complex coefficients in the vector a of the
  ; polynomial (sum (i 0 m) a_i * x^i ) and a complex value
  ; x this routine improves x by Laguerre's method until
  ; it converges to a root of the polynoial.

  (define-syntax vr
(syntax-rules () [(_ v i)   (vector-ref  v i)]))
  (define-syntax vs!
(syntax-rules () [(_ v i x) (vector-set! v i x)]))
  (define-syntax define*
(syntax-rules ()
  [(_ () v)   (begin)]
  [(_ (id ids ...) v) (begin (define id v) (define* (ids ...) v))]))
  (define-syntax :=  (syntax-rules () [(_ id v) (set! id v)]))

  (define* (iter its j MAXIT) 1)
  (define* (abx abp abm err) 0.0)
  (define* (dx x1 b d f g h sq gp gm g2) 0.0)
  (define frac (vector 0.0 0.5 0.25 0.75 0.13 0.38 0.62 0.88 1.0))

  (define MR 8)
  (define MT 10)
  (define EPSS 1.0e-7)
  (set! MAXIT (* MT MR))
  (let ([return #f])
(do ([iter 1 (+ iter 1)]) [(or return ( iter MAXIT))]
  (:= its iter)
  (:= b (vr a m))
  (:= err (abs b))
  (:= f 0.0+0.0i)
  (:= d f)
  (:= abx (magnitude x))
  (do ([j (- m 1) (- j 1)]) [(or return ( j 0))]
(:= f (+ (* x f) d))
(:= d (+ (* x d) b))
(:= b (+ (* x b) (vr a j)))
(:= err (+ (magnitude b) (* abx err
  (:= err (* err EPSS))
  (if (= (magnitude b) err)
  (set! return x)
  (begin
(:= g (/ d b))
(:= g2 (* g g))
(:= h (- g2 (* 2.0 (/ f b
(:= sq (sqrt (* (- m 1) (- (* m h) g2
(:= gp (+ g sq))
(:= gm (- g sq))
(:= abp (magnitude gp))
(:= abm (magnitude gm))
(if ( abp abm)
(:= gp gm))
(:= dx (if ( (max abp abm) 0.0)
   (/ m gp)
   (* (+ 1 abx)
  (+ (cos iter) (* (sin iter) 0.0+1.0i)
(:= x1 (- x dx))
(if (= x x1)
(set! return x)
(begin
  (if (= 0 (modulo iter MT))
  (:= x x1)
  (:= x (- x (* (/ iter MT) dx)
(if return
return
(error
 polynomial-roots-laguerre: too many iterations - try another
guess

(define (polynomial-roots-all a m roots)
  ; Given the complex coefficients in the vector a of the
  ; polynomial (sum (i 0 m) a_i * x^i ) the degree m
  ; (if a is longer than m the end of a is ignored)
  ; this routine fills the vector roots with
  ; the roots
  (define-syntax vr
(syntax-rules () [(_ v i)   (vector-ref  v i)]))
  (define-syntax vs!
(syntax-rules () [(_ v i x) (vector-set! v i x)]))
  (define-syntax define*
(syntax-rules ()
  [(_ () v)   (begin)]
  [(_ (id ids ...) v) (begin (define id v) (define* (ids ...) v))]))
  (define-syntax :=  (syntax-rules () [(_ id v) (set! id v)]))
  (define-syntax --  (syntax-rules () [(_ n) (sub1 n)]))

  (define polish #t)
  (define EPS 2.0e-6)
  (define MAXM 100)

  (define* (i its j jj) 0)
  (define* (x b c) 0.0)
  (define ad 0)
  (set! ad (make-vector MAXM 0.0))

  (do ([j 0 (+ j 1)]) [( j m)]
(vs! ad j (vr a j)))
  (do ([j m (- j 1)]) [( j 1)]
(:= x 0.0+0.0i)
(:= x (polynomial-roots-laguerre ad j x))
(if (= (abs (imag-part x)) (* 2.0 EPS

[Chicken-users] foreign-lambda - how to declare double array as argument and how to pass things to it?

2007-11-11 Thread Terrence Brannon
I have this function in C:

double polevl( x, coef, N )
double x;
double coef[];
int N;
{
 ...
}

and I am trying to create foreign-lambda for it:

(define polevl
  (foreign-lambda double polevl double f64vector int))

But I know that double[] is wrong.

My guess was f64vector. That compiled, but passing a Scheme vector in failed:

#;2 (let ([vec (vector 0 1 1)]) (polevl 42 vec (vector-length vec)))
Error: bad argument type - not a number-vector or not of the correct type
#(0 1 1)
f64vector

Call history:

syntax(let ((vec (vector 0 1 1))) (polevl 42 vec 
(vector-length vec)))
syntax(begin (polevl 42 vec (vector-length vec)))
syntax(polevl 42 vec (vector-length vec))
syntax(vector-length vec)
syntax(vector 0 1 1)
eval  (vector 0 1 1)
eval  (polevl 42 vec (vector-length vec))
eval  (vector-length vec) --
#;2


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] #(a b c) not accepted as vector of symbols

2007-11-11 Thread Terrence Brannon
why would chicken not accept that syntax as a vector of symbols? plt did.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] stepwise visual execution of functions

2007-11-04 Thread Terrence Brannon
After I develop a function, I want to see what happens to the input
data as it hits each step of the function to make sure it is working
correctly. For example, in the following function:

(define (mraze a)
  (let* ([unboxed-a (unbox-array a)]
 [unboxed-l (array-list unboxed-a)]
 [item-shapes (map item-shape unboxed-l)]
 [data-ranks (map my-array-rank unboxed-l)]
 )
(if (all-equal? = item-shapes)
(if (= (apply max data-ranks) 1)
(apply rank-1 (flatten (map array-items unboxed-l)))
#t)
#f)))


I would like to pass in a data-item, and then see the value of
unboxed-a and then step once more and see the value of unboxed-l and
so on, all the way through the procedure.

Any suggestions for how to visually see what my functions are doing?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-lib : prepending unit axes

2007-11-04 Thread Terrence Brannon
i wrote a function to prepend unit axes onto an array. this is
oftentimes necessary to get arrays to the same rank before applying
some sort of operation to them.

if there is a better way to do this, I'm all ears. Please, no comments
about my parenthesizing style :)

(define prepend-unit-axes
  (lambda (n a)
(if (= n 0)
a
(let* (
   [ones (make-list n 1)]
   [new-dim (flatten ones (array-dimensions a))]
   [as-v (array-vector a)]
   [as-l (vector-list as-v)]
   )
  (apply array '#() new-dim as-l)


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution

2007-10-29 Thread Terrence Brannon
On 10/29/07, Ivan Raikov [EMAIL PROTECTED] wrote:


  What platform is this on?

cygwin

 Instead of commenting out the typedefs,
 could you please rename all the type definitions in randmtzig.c and
 random-mtzig.scm as follows:

 Original:

 typedef signed char int8_t;
 ...

 Modified:

 typedef signed char randmtzig_int8_t;

(abbreviated output of cat random-mtzig.egg-dir/randmtzig.c )
typedef int randmtzig_idx_type;
typedef signed char randmtzig_int8_t;
typedef unsigned char randmtzig_uint8_t;
typedef short randmtzig_int16_t;
typedef unsigned short randmtzig_uint16_t;
typedef int randmtzig_int32_t;
typedef unsigned int randmtzig_uint32_t;
typedef long long randmtzig_int64_t;
typedef unsigned long long randmtzig_uint64_t;

(abbreviated output of cat random-mtzig.egg-dir/random-mtzig.scm )

(define-extension random-mtzig)

(require-extension srfi-4)

#!

typedef int randmtzig_idx_type;

typedef signed char randmtzig_int8_t;
typedef unsigned char randmtzig_uint8_t;

typedef short randmtzig_int16_t;
typedef unsigned short randmtzig_uint16_t;

typedef int randmtzig_int32_t;
typedef unsigned int randmtzig_uint32_t;

typedef unsigned int randmtzig_uint64_t;

___declare(export_constants, yes)


[EMAIL PROTECTED] /tmp :


 This should avoid all collisions with definitions in stdint.h. Let me
 know if this works for you.

[EMAIL PROTECTED] /tmp : chicken-setup random-mtzig
  /usr/local/bin/csc -feature compiling-extension -O -d2 -X easyffi -s
-o random-mtzig.so -check-imports -emit-exports random-mtzig.exports
random-mtzig.scm randmtzig.c -lchicken -ldl -lm
Error: during expansion of (foreign-parse ...) - do not know how to
compute length of foreign type argument: (pointer uint32_t)

Call history:

eval  (append strs (quote (\n)))
eval  (check-c-syntax (string-concatenate strs) (quote 
foreign-declare))
eval  (string-concatenate strs)
eval  (every string? strs)
eval  (##sys#list (quote ##core#declare) (##sys#list (quote 
quote)
(##sys#cons (quote foreign-declare) str..
eval  (##sys#list (quote quote) (##sys#cons (quote 
foreign-declare) strs))
eval  (##sys#cons (quote foreign-declare) strs)
syntax(##core#declare (quote (foreign-declare 
\n\ntypedef int
randmtzig_idx_type;\n\ntypedef signed char...
syntax(begin (##core#undefined))
syntax(##core#undefined)
syntax(foreign-parse \n\ntypedef int
randmtzig_idx_type;\n\ntypedef signed char randmtzig_int8_t;\ntyped...
eval  (append strs (quote (\n)))
eval  (every string? strs)
eval  (##sys#cons (quote begin) (parse-easy-ffi 
(string-concatenate strs)))
eval  (parse-easy-ffi (string-concatenate strs))
eval  (string-concatenate strs)   --
*** Shell command terminated with exit status 70:
/usr/local/bin/chicken random-mtzig.scm -output-file random-mtzig.c
-dynamic -feature chicken-compile-shared -quiet -feature
compiling-extension -optimize-level 1 -debug-level 2 -extend easyffi
-check-imports -emit-exports random-mtzig.exports
Error: shell invocation failed with non-zero return status
/usr/local/bin/csc -feature compiling-extension -O -d2 -X easyffi -s
-o random...
70
[EMAIL PROTECTED] /tmp :


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution

2007-10-29 Thread Terrence Brannon
On 10/29/07, Ivan Raikov [EMAIL PROTECTED] wrote:


  Uniformly-distributed integers can be generated with the
 random-mtzig:random! procedure.

procedure: random-mtzig:random! :: STATE - INTEGER
Returns a random integer value between 0 and the largest
machine-representable unsigned integer on the current platform.

I am looking for a procedure with this signature:

some-func :: STATE - INTEGER - INTEGER

It takes a state and an integer n and returns an integer in the interval [0,n)


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution

2007-10-29 Thread Terrence Brannon
Ok, I'm getting build problems between data definitions in stdint.h
and some of the source code in random-mtzig

Here was the first error I got:

downloading random-mtzig.egg from
(www.call-with-current-continuation.org eggs 80) .
  gunzip -c ../random-mtzig.egg | tar xf -
  /usr/local/bin/csc -feature compiling-extension -O -d2 -X easyffi -s
-o random-mtzig.so -check-imports -emit-exports random-mtzig.exports
random-mtzig.scm randmtzig.c -lchicken -ldl -lm
randmtzig.c:1: warning: -fPIC ignored for target (all code is position
independent)
randmtzig.c:144: error: conflicting types for 'int32_t'
/usr/include/stdint.h:20: error: previous declaration of 'int32_t' was here
randmtzig.c:145: error: conflicting types for 'uint32_t'
/usr/include/stdint.h:28: error: previous declaration of 'uint32_t' was here

contents of stdint.h
LINE 20typedef long int32_t;/LINE
LINE 28typedef unsigned long uint32_t;/LINE
/contents

So I commented out the typedefs in randmtzig.c but then I ran into
this compilation issue:

[EMAIL PROTECTED] /tmp : chicken-setup random-mtzig
  /usr/local/bin/csc -feature compiling-extension -O -d2 -X easyffi -s
-o random-mtzig.so -check-imports -emit-exports random-mtzig.exports
random-mtzig.scm randmtzig.c -lchicken -ldl -lm
randmtzig.c:1: warning: -fPIC ignored for target (all code is position
independent)
random-mtzig.c:1: warning: -fPIC ignored for target (all code is
position independent)
random-mtzig.c:21: error: conflicting types for 'int32_t'
/usr/include/stdint.h:20: error: previous declaration of 'int32_t' was here
random-mtzig.c:22: error: conflicting types for 'uint32_t'
/usr/include/stdint.h:28: error: previous declaration of 'uint32_t' was here


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] csc / compile - how to pass things to gcc?

2007-10-29 Thread Terrence Brannon
I want all calls to gcc from Chicken csc to pass

-D__uint32_t_defined -D__int8_t_defined

but I do not know how to modify this compile call so that happens.
please advise:

(compile -O -d2 -X easyffi -s -o random-mtzig.so
 ,@(if has-exports? '(-check-imports -emit-exports 
random-mtzig.exports) '())
 random-mtzig.scm randmtzig.c -lchicken -ldl -lm)


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] unit-extras random - is it a uniform distribution

2007-10-28 Thread Terrence Brannon
Re: http://galinha.ucpel.tche.br:8080//Unit%20extras#random

Do the numbers from the unit extras random function follow a uniform
distribution?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution

2007-10-28 Thread Terrence Brannon
In addition to the bug I filed on this egg - http://trac.callcc.org/ticket/346

I have a question about common usage of this module.

I would like to produce one function, roll-fixed, which produces
pseudorandom numbers in the documented fashion of random-real and
random in SRFI-27. Such that the sequence of randoms (over a uniform
distribution) is predictable on each new startup of the intepreter:

(define *fixed-seed* (expt 7 5))

(define roll-fixed
  (let ([side-effect (set-seed *fixed-seed*)])
 (lambda (n)
(if (zero? n)
(random-real-based-on-fixed-seed)
(random-integer-based-on-fixed-seed n)

Additionally, I would like a function, roll-truly-random, which again
can produce reals or integer randoms, but whose sequence of randoms
(over a uniform distribution) is different across each new startup of
the interpreter.

(define roll-truly-random
  (let ([side-effect (set-seed (truly-random-seed))])
 (lambda (n)
(if (zero? n)
(random-real-based-on-truly-random-seed)
(random-integer-based-on-truly-random-seed n)


I'm sorry to beg for such hand-holding, but it seems like the Issues
section of the docs does admit that this library could use a few good
examples. It also mentions that the API creates something of a hurdle
for my desire to have two distinct random structures available in two
distinct functions.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] srfi-27 - producing pseudo and truly random numbers over a uniform distribution

2007-10-28 Thread Terrence Brannon
On 10/28/07, Ivan Raikov [EMAIL PROTECTED] wrote:

 Hello,

Does the random-mtzig egg do what you need?

It looks better, because you just seed the state as you please and
then consistently pass the state. This means I can have one RNG that
uses the same seed across interpreter invocations and another that is
truly random.

I dont know why things like SRFI-27 get ratified and have the
inconsistency that Kon discusses in the Issues section of his docs:
http://www.call-with-current-continuation.org/eggs/srfi-27.html

With your mtzig library, I see how to create a uniformly distributed
real from (0,1)
but I do not see how to create a uniformly distributed integer from
[0,n) where n is some number not necessarily the largest on the
machine.

Also, i do not understand why you did not pass in the created state in
your example at the end:

csi (require-extension random-mtzig)
csi (random-mtzig:init! 24)
csi (random-mtzig:f64vector-randu! 20)

The docs say that N * state (which I assume is a 2-tuple of an integer
and the previously created state) is passed to that function.

In fact, the docs are confusing because the type signatures imply that
the functions take a state, but then the example at the bottom does
not supply a state to random-mtzig:f64vector-randu!

Compare these signatures:
procedure: random-mtzig:init :: [SEED] - STATE
procedure: random-mtzig:random! :: STATE - INTEGER

In the first procedure SEED is an optional argument, in the second
STATE is not indicated as optional. It must be supplied.

 It can be seeded from
 /dev/urandom, or with a constant supplied by the user, and you could
 have multiple seed states that are passed to the random number
 generating routines in the egg. I can also add some convenience
 functions, if they would fit your needs better.

Based on your API, here is what I would be aiming for:

(define *fixed-seed* (expt 7 5))

(define fixed-state (random-mtzig:init *fixed-seed*))

(define (roll-fixed n)
   (if (zero? n)
(random-mtzig:randu! fixed-state)
(random-mtzig:random-from-zero-to-n n fixed-state)  ; [0,n)
))

(define random-state (random-mtzig:init)

(define (roll-random n)
   (if (zero? n)
(random-mtzig:randu! random-state)
(random-mtzig:random-from-zero-to-n n random-state)  ; [0,n)
))


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] changing default directory for csi

2007-10-22 Thread Terrence Brannon
The csi takes relative load commands based on the directory that csi
was started in. Is there a procedure call I can make after invoking
csi that will change the default directory to somewhere else?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] the effect of set! on the top-level namespace

2007-10-15 Thread Terrence Brannon
I would like to know:
* what is happening to the symbol afunc in line 1 versus line 3. In
particular is the same memory location being over-written?
* Also, in line 2 is first-func being set to a value which is not destroyed by
the set! call in line 3?
* I think I was anticipating that first-func would assume the behavior
of second-func once afunc was re-defined.
* Finally, there is no need to make things complicated by using set!
since the define version has the same behavior. But for some code I am
writing personally, I have to use set! because define inside a let
does not seem to affect the top-level the way I need it to.

(set! afunc (lambda (x) (+ x 5)))  ;;; line 1
(set! first-func afunc)
(set! afunc (lambda (x) (* x 1000)))  ;;; line 3
(set! second-func afunc)

(first-func 1)
(second-func 1)

(afunc 1) ; same as second-func

;;; define version
(define afunc (lambda (x) (+ x 5)))
(define first-func afunc)
(define afunc (lambda (x) (* x 1000)))
(define second-func afunc)

(first-func 1)
(second-func 1)

(afunc 1) ; same as second-func


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-lib : how to make a rank-1 array with no elements?

2007-10-11 Thread Terrence Brannon
I tried a few things, but couldnt get it to work

(array '#() '(1)) ; Error: (array) wrong number of elements to construct array

(make-array '#() '(1)) ; Error: (vector-ref) out of range


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] numbers egg - (angle y) feedback

2007-10-11 Thread Terrence Brannon
I tried to re-open the ticket on trac, but was told my submission was potential 
spam.

The (angle) function does not coredump. But it gives a result of 0.0 for an 
argument of 2, which I do not think is correct. The same function in J gives 

-0.416147+0.909297i

Here is a link to the J function, whose name is r.  ... that's right... r 
dot
http://www.jsoftware.com/help/dictionary/drdot.htm

The thing is, most J functions have a monadic and dyadic case. The monadic case 
is relevant in this case and has this description: The result of r. y is a 
complex number of magnitude 1, whose real and imaginary parts are coordinates 
of the point on the unit circle at an angle of y radians.




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] egg creation - documentation and finishing touches help needed

2007-10-09 Thread Terrence Brannon
I need some mentoring to get my first egg finished.

Documentation - what is the protocol for documenting an egg? It looks
like an external HTML file is supplied, but is there some text-html
converter?

Testing - how do I test this egg before uploading it? There doesnt
seem to be a way to point chicken-setup at a local egg.

Upload - how/where do I upload it?

Here is a link to the egg as far as I have taken it -
http://fyodor.hcoop.net/~terry/tmp/matpak.egg


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Choosing a programming language for a web project

2007-09-29 Thread Terrence Brannon
On 9/29/07, Jean-Philippe Théberge [EMAIL PROTECTED] wrote:

 So the question is: Is programmer recruitement that important and are good
 scheme programmer so rare?

Must the programmers be on-site? If so, what location?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-lib : array-join when innermost datum is an array itself

2007-09-25 Thread Terrence Brannon
If I have an array with dimension-list '(2 3) whose contents at each
position is an array of dimension-list '(4 5), how can I use
array-join to create an array of
dimension-list '(2 3 4 5)

I would post the code, but:
1 - I think this question is easy for anyone who knows the API well [Kon :)]
2 - the code to generate the  is very involved. If you would like to
get it then simply

a) Unzip http://hg.metaperl.com/redick/archive/aae0c0bbe51b.zip
b) load the file verbs.scm which will load everything else.
c) load the file scheme/issues/how-to-array-join.scm which will create
an array of dimension '(2 3) which has elements of dimension '(4 5)


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] emacs editing mode for chicken ?

2007-09-24 Thread Terrence Brannon
On 9/19/07, Tony Sidaway [EMAIL PROTECTED] wrote:

 If you do use quack.el, you should perform the following edits:

 In ~/.emacs

 Add (load-file ~/quack.el)

I think byte-compiling quack.el and putting:

   (require 'quack)

would make things faster and more memory efficient.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-lib - reversing a rank-1 array issue

2007-09-22 Thread Terrence Brannon
array-split/shared is having an issue, saying rank must be lower than 
dimensionality

1) I'm assuming dimensionality means (length dimension) since it is not defined 
in the docs and that would make the rank and dimensionality equal, hence the 
error
2) Should it be possible to reverse a rank-1 array?

(require-extension array-lib)

(define (rank-1 . elems)
  (apply array (list (length elems)) elems))

#;33 (array-reverse (rank-1 7 82 2 23))
Error: (array-split/shared) rank must be lower than dimensionality



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] array-lib - reversing a rank-1 array issue

2007-09-22 Thread Terrence Brannon
IGNORE THIS. I think GMANE sent it. It has already been addressed.

On 9/14/07, Terrence Brannon [EMAIL PROTECTED] wrote:
 array-split/shared is having an issue, saying rank must be lower than
 dimensionality

 1) I'm assuming dimensionality means (length dimension) since it is not 
 defined
 in the docs and that would make the rank and dimensionality equal, hence the
 error
 2) Should it be possible to reverse a rank-1 array?

 (require-extension array-lib)

 (define (rank-1 . elems)
   (apply array (list (length elems)) elems))

 #;33 (array-reverse (rank-1 7 82 2 23))
 Error: (array-split/shared) rank must be lower than dimensionality



 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] (issue) array-lib - array-copy of rank-1 array with complex elements

2007-09-18 Thread Terrence Brannon
(require-extension array-lib)

(define (rank-1 . elems)  (apply array (list (length elems)) elems))
(define a (rank-1 (make-rectangular 3 4)  (make-rectangular 6 8)))

;;; http://www.call-with-current-continuation.org/eggs/array-lib.htm
;; procedure: (array-copy [PROTOTYPE] ARRAY)
;; Returns a copy of the array. When prototype is missing a deep copy is
;; performed.
(array-copy a)   ;;; Error: out of range

;; When the prototype and the source array are the same,
;; (eq? PROTOTYPE ARRAY),
;; a fresh array is returned with the same shape, using the array as the
;; prototype.
(array-copy a a) ;;; drops the 2nd element of the array. actually,
I'm thinking that it
;;; might be using the first element as a prototype for the rest of
the array. But the docs
;;; say it uses the array as prototype, not the first element of it.

;; Otherwise a fresh array is returned with the specified
;; prototype and elements from the array.
(array-copy '#() a)  ;;; works


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] mathh does not compile on cygwin

2007-09-17 Thread Terrence Brannon
[EMAIL PROTECTED] /tmp : chicken-setup mathh

The extension mathh does not exist.
Do you want to download it ? (yes/no/abort) [yes]
downloading mathh.egg from (www.call-with-current-continuation.org eggs 80)
  gunzip -c ../mathh.egg | tar xf -
.  /usr/local/bin/csc -feature compiling-extension -s -O2 -d1
mathh-int.scm -o mathh-int.dll -check-imports -emit-exports
mathh-int.exports -feature has-long-long-type
mathh-int.c:1: warning: -fPIC ignored for target (all code is position
independent)
mathh-int.c:19: error: conflicting types for 'uint32_t'
/usr/include/stdint.h:28: error: previous declaration of 'uint32_t' was here
*** Shell command terminated with exit status 1: gcc mathh-int.c -o
mathh-int.o -c -DHAVE_CHICKEN_CONFIG -Os -fomit-frame-pointer
-fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized
-DC_ENABLE_PTABLES -DC_NO_PIC_NO_DLL -fPIC -DPIC -DC_SHARED -I
/usr/local/include
Error: shell invocation failed with non-zero return status
/usr/local/bin/csc -feature compiling-extension -s -O2 -d1
mathh-int.scm -o ma...
1
[EMAIL PROTECTED] /tmp :


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-lib - reversing a rank-1 array issue

2007-09-14 Thread Terrence Brannon
array-split/shared is having an issue, saying rank must be lower than
dimensionality

1) I'm assuming dimensionality means (length dimension) since it is
not defined in the docs and that would make the rank and
dimensionality equal, hence the error
2) Should it be possible to reverse a rank-1 array?

(require-extension array-lib)

(define (rank-1 . elems)
  (apply array (list (length elems)) elems))

#;33 (array-reverse (rank-1 7 82 2 23))
Error: (array-split/shared) rank must be lower than dimensionality


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] array-list does not return a list for a rank-1 array

2007-09-14 Thread Terrence Brannon
Re: http://www.call-with-current-continuation.org/eggs/array-lib.html
Quote: procedure: (array-list ARRAY)

Returns the array elements as a rank-nested list. For rank 0 arrays returns
just the element.

== This implies

a list should be returned for rank-1 arrays

== However

For a rank-1 list consisting of 1 element, it does not return a list:

(require-extension array-lib)


(define (rank-1 . elems)
  (apply array (list (length elems)) elems))



#;90 (array-rank (rank-1 4 5))
1
#;91 (array-rank (rank-1 4))
1
#;93 (list? (array-list (rank-1 4 5)))
#t
#;94 (list? (array-list (rank-1 4 )))
#f


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] A scheme library for J programming is not re-inventing the wheel is it?

2007-09-11 Thread Terrence Brannon
On 9/11/07, Sunnan [EMAIL PROTECTED] wrote:
 Terrence Brannon wrote:
  I've been a fan of J for a long time, and have an implementation of
  monadic array processing in J fashion finished. has this sort of thing
  been done before? i'm planning on extending it to other J processing
  idioms as well.
 
 This is pretty sweet!

Thanks. It took a lot of work (and re-work and rework...). But I owe
much of the success to Kon Lovett and his array-lib.

 Have you seen Aubrey Jaffer's APL-inspired work on SCM?

No and googling only led to this -
http://www-swiss.ai.mit.edu/~jaffer/CNS/interpreter-speed


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] A scheme library for J programming is not re-inventing the wheel is it?

2007-09-10 Thread Terrence Brannon
I've been a fan of J for a long time, and have an implementation of
monadic array processing in J fashion finished. has this sort of thing
been done before? i'm planning on extending it to other J processing
idioms as well.

If you want to play with the source, d/l and install instructions are at
http://redick.metaperl.com

# Apologies in advance to Kon for use of the word shape :)
.
#;2 (define n (quikary 2 3 4))
#;3 n
#,(array vector ((0 . 1) (0 . 2) (0 . 3)) (((0 1 2 3) (4 5 6 7) (8 9
10 11)) ((12 13 14 15) (16 17 18 19) (20 21 22 23
.

.Now perform Tally on it with the default infinite rank
.
#;4 (Tally n)
2
.

As expected, `Tally` tells us that the entire array has 2 items. Let's
use the rank conjunction to produce a version of `Tally` that has
default rank of 2 instead:
.
#;5 (define New-Tally-2 (Rank Tally 2))
#;6 (New-Tally-2 n)
#(3 3)
.

We told tally that we wanted to process this data as 2-cells stuffed in
a frame of shape 2. And so we got back a result for each frame
position and since there are 3 items in each `3x4` 2-cell, the answer
is 3.

Now let's process our data as a series of 1-cells:
.
#;7 (define New-Tally-1 (Rank Tally 1))
#;9 (New-Tally-1 n)
#,(array vector ((0 . 1) (0 . 2)) ((4 4 4) (4 4 4)))
.

And finally, let's process the array with rank-0:
.
#;10 (define New-Tally-0 (Rank Tally 0))
#;11 (New-Tally-0 n)
#,(array vector ((0 . 1) (0 . 2) (0 . 3)) (((1 1 1 1) (1 1 1 1) (1 1 1
1)) ((1 1 1 1) (1 1 1 1) (1 1 1 1
..


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] array-lib-hof - array-map! - not sure it's working

2007-09-09 Thread Terrence Brannon
On 9/9/07, Kon Lovett [EMAIL PROTECTED] wrote:

 On Sep 8, 2007, at 2:49 PM, Terrence Brannon wrote:

  (require-extension array-lib)
  (require-extension array-lib-hof)
 
  (define (quikary shape)
(let ([element-count (apply * shape)])
  (apply array shape (iota element-count
 
  (define h (quikary '(2 3)))

 Quibble - 'shape' above isn't a shape but dimensions

Yes, I tend to fall into J terminology


 
  ; (array-map! h (lambda (z y x) ho))  doesnt throw an arity
  error. doesnt change h

 The procedure is never called. You didn't provide any array(s) to
 map. The signature  semantics are per the SLIB procedure of the same
 name.

Ok, but my usual understanding of function documentation is that
anything in brackets is optional. And the signature here -
http://www.call-with-current-continuation.org/eggs/array-lib.html

is procedure: (array-map! ARRAY PROCEDURE [ARRAY ...])

and then note that the docs say:

Apply the procedure to each element of the array(s).

since the plural is parenthesized, that also means that anything
beyond one array is optional.


  ; (array-index-map! h (lambda (y x) ho))  changes contents of h

 The procedure takes the indices, not the elements. Your array is rank
 2, so your procedure has the correct number of parameters.

Yes, I will hijack array-index-map! even though I really didnt need
the indices for anything in particular.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] highlevel macros are not supported error

2007-09-09 Thread Terrence Brannon
When I attempt to use pos.scm I get this error -

#;9 ; loading /usr/local/lib/chicken/1/pos.scm ...
Error: (define-syntax) during expansion of (define-syntax ...) -
highlevel macros are not supported

Call history:

syntax(require-extension pos)
syntax(##core#require-extension (quote pos))
syntax(begin (begin (##core#require-for-syntax (quote 
pos))
(##sys#require (quote pos-support))) (##core#u..
syntax(begin (##core#require-for-syntax (quote pos))
(##sys#require (quote pos-support)))
syntax(##core#require-for-syntax (quote pos))
syntax(quote pos)
syntax(define-syntax define-class (syntax-rules 
(superclasses
cvars ivars cmeths imeths fix-args) ((_ clas..  --
#;9

How can I fix this?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] does protobj work?

2007-09-09 Thread Terrence Brannon
it does not seem to work:

(require-extension protobj)


(define a (%))


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] synonyms for module sought

2007-09-08 Thread Terrence Brannon
On 9/7/07, Peter Bex [EMAIL PROTECTED] wrote:

 How about 'yolk'?  It's what eggs are made of/what's inside eggs.


yes, I think yolk is an awesome name.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] (array-strict? (make-array '#() 7)) ; should return #t right?

2007-09-04 Thread Terrence Brannon
(require-extension array-lib)

(array-strict? (make-array '#() 7)) ; should return #t


However, it returns false... it seems to be a strict array to me.

I do need for a 1-dimensional structure created by make-array to be
testable by some predicate for a procedure I have written called
Shape, analagous to the J verb by the same name:

#;47 (array-strict? (Shape '(8) 5))
#f
#;48 (array-strict? (Shape '(1 8) 5))
#t

In J, both of these are arrays. The first is a rank-1 array and the
second is a rank-2 array.

This is the Shape procedure:


(define (Shape dim-list . data)
  (let* ([dimension-list (if (list? dim-list) dim-list (list dim-list))]
 [prototype '#()]
 [dimensions (apply make-array-dimensions dimension-list)]
 [cardinality (apply * dimension-list)]
 [data-size (lambda () (length data))]
 [list-logic (lambda (L)
   (cond
((= (data-size) cardinality) data)
(( (data-size) cardinality) (take data cardinality))
(( (data-size) cardinality)
 (take (apply circular-list data) cardinality]
 [data* (if (list? data)
(list-logic data)
(make-list cardinality data))]
 [vektor (list-vector data*)])
(apply vector-array vektor prototype dimension-list)))


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] complex library package issue

2007-09-01 Thread Terrence Brannon
Hello, the complex package is turning the addition of two lists which
start with zero into a complex result when it should just be another
list. Case synopsis:

(Plus '(0 1 2 3) '(0 1 2 3))  ;; yields a complex!
(Plus '(1 2 3) '(1 2 3))  ;; yields a list, as expected
(Plus  3 '(1 2 3));; yields a list, as expected
(Plus  3 4)   ;; yields a scalar, as expected

The code which follows will exemplify this behavior, as long as you
get all the eggs that it requires:

chicken-setup array-lib complex

(require-extension array-lib)
(require-extension array-lib-hof)
(require-extension complex)


(use srfi-1)

; http://srfi.schemers.org/srfi-63/srfi-63.html
(define (strict-array? obj)
  (and (array? obj) (not (string? obj)) (not (vector? obj


(define (map-wrap proc . lists)
  (cond
   ((any strict-array? lists)
(let* ([newlists (apply array-agree lists)])
  (apply array-map '#() proc newlists)))
((any (lambda (x) (and list? (not (complex? x lists)
 (apply map
 proc
 (map (lambda (x)
(if (not (pair? x))
(circular-list x)
x))
  lists)))
(else (apply proc lists

(define (Shape dim-list . data)
  (let* ([dimension-list (if (list? dim-list) dim-list (list dim-list))]
 [prototype '#()]
 [dimensions (apply make-array-dimensions dimension-list)]
 [cardinality (apply * dimension-list)]
 [data-size (lambda () (length data))]
 [list-logic (lambda (L)
   (cond
((= (data-size) cardinality) data)
(( (data-size) cardinality) (take data cardinality))
(( (data-size) cardinality)
 (take (apply circular-list data) cardinality]
 [data* (if (list? data)
(list-logic data)
(make-list cardinality data))]
 [vektor (list-vector data*)])
(apply vector-array vektor prototype dimension-list)))


(define (Plus m n) (map-wrap + m n))

(Plus '(0 1 2 3) '(0 1 2 3))  ;; yields a complex!
(Plus '(1 2 3) '(1 2 3))  ;; yields a list, as expected
(Plus  3 '(1 2 3));; yields a list, as expected
(Plus  3 4)   ;; yields a scalar, as expected


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users