Re: [Chicken-users] generate numerical list

2016-07-11 Thread Jeremy Steward

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 11/07/16 08:57 PM, John Cowan wrote:
| Jeremy Steward scripsit:
|
|> Note that iota annoyingly does not work well with the numbers egg
|> ->
|
| This is a general problem with the numbers egg and all other
| Chicken code, whether part of the main build or an egg.  If the
| code is not *compiled* with the numbers egg, it will not know
| anything about ratios, bignums, or complex numbers.
|

You are indeed correct on this. I apologize if I made it seem
otherwise, as IIRC you can get many things working with the numbers
egg by using the following:

~$ csc -X numbers ...

| Chicken 5 will have a full numeric tower natively and won't have
| this problem.

And thanks to Peter for this and many other great things.

- -- 
Jeremy Steward


-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCAAGBQJXhF2DAAoJEKflx7ZMcbY79B8P/RXzzHoHDkABY2hopNJfazXy
BFQVXko9P2MkVjS1Idl796FVPZVa9HA5quKeJLGj7pX12OZ5hYcZx9GG7jLGrMQF
dq07Eo/iswfHWZXobCEcfqu/P7tOzXbHqqgDtzZS50HX+WLpTuhM4+S/QP/x30Id
vBmV3tj2/JDO8U0yWol/212tySV2DZ8iLi3iHuuLCX50fPXGcGIVVS7jU1vC2Dme
2lmZEmdT92BtV4htpT4e0CtRi/eaAWTRfxCksfbdVy3TEkXaAo9yUWvhL4tFFyMF
A+Il3kG9tS76w20y+nIhhIjocegMBUVWLZSPHxJrihr6gWPUA6vwmCZwEMCIFsaA
LYx22yG3PLrejD2LQMLBcE/x+gTEnsxEdXsSFnU3YV97LSaEST1cbAQOpMlRdnx+
dKOmc8Ym3eZ7Vsu9K4/h3Bgg74D14aVk5XzRS9VVt5+p3S+8LkmxXabYe/7H4irT
R+Y5Hf72LcRAFAZ/5lT+GooucYyVF1xbrNoWdi4Y3j0bgYg98sL2M7jgVwApiSjr
bd3hcWEJfpH3SuyB95R2mMsdHSrGwjBwpANvM0e5fuuT8kS+QeHv+gIUB4BkYuF4
uTuyaHv4ic6S9ZcLlKo0JHb4e9kis86jJqpsmvIfzUWDw8XN4hKL7iMadR5VMuEg
LLEOI08pb2PqQEUvvC9i
=uy7o
-END PGP SIGNATURE-

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


Re: [Chicken-users] generate numerical list

2016-07-11 Thread John Cowan
Jeremy Steward scripsit:

> Note that iota annoyingly does not work well with the numbers egg ->

This is a general problem with the numbers egg and all other Chicken code,
whether part of the main build or an egg.  If the code is not *compiled*
with the numbers egg, it will not know anything about ratios, bignums,
or complex numbers.

Chicken 5 will have a full numeric tower natively and won't have this problem.

-- 
John Cowan  http://www.ccil.org/~cowanco...@ccil.org
If you have ever wondered if you are in hell, it has been said, then
you are on a well-traveled road of spiritual inquiry.  If you are
absolutely sure you are in hell, however, then you must be on the Cross
Bronx Expressway.  --Alan Feuer, New York Times, 2002-09-20

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


Re: [Chicken-users] generate numerical list

2016-07-11 Thread Jinsong Liang
Thank you Jeremy! Your code is very helpful.

Jinsong

On Mon, Jul 11, 2016 at 10:43 PM, Jeremy Steward 
wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Note that iota annoyingly does not work well with the numbers egg ->
> it cannot figure out what an exact rational should be. So:
>
> ~ (use srfi-1 numbers)
> ~ (iota 1 10 (/ 3 2))
>
> outputs:
>
> ~ Error: (iota) bad argument type - not a number: 3/2
>
> Instead, you could define your own `iota` procedure after importing
> the numbers egg using `unfold`, or you could define something like
> MATLAB's `linspace`:
>
> ~ (define (my-iota count #!optional (start 0) (step 1))
> ~   (unfold (lambda (x) (>= (/ (- x start) step) count))
> ~   (lambda (x) x)
> ~   (lambda (x) (+ x step))
> ~   start))
>
> ~ (define (linspace base limit n)
> ~   (unfold (lambda (x) (> x limit))
> ~   (lambda (x) x)
> ~   (lambda (x) (+ x (/ (- limit base)
> ~   (- n 1
> ~   base))
>
> ~ (linspace 1 10 10) ;=> (1 2 3 4 5 6 7 8 9 10)
> ~ (linspace 0 50 5)  ;=> (0 25/2 25 75/2 50)
>
> I'm sure I'm omitting some error checking in the above (for sequences
> that would end up infinite), but it should get you on the right track
> if you do find that SRFI-1 does not suffice when using exact rationals.
>
> Regards,
>
>
> On 11/07/16 08:21 PM, Evan Hanson wrote:
> | Hi Jinsong,
> |
> | SRFI-1 provides `iota' -- http://api.call-cc.org/doc/srfi-1/iota
> |
> | Cheers,
> |
> | Evan
> |
> | ___ Chicken-users
> | mailing list Chicken-users@nongnu.org
> | https://lists.nongnu.org/mailman/listinfo/chicken-users
> |
>
> - -- Jeremy Steward
>
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2
>
> iQIcBAEBCAAGBQJXhFlbAAoJEKflx7ZMcbY7zIoQAJnzUGexanBT0TbCv+si8ikG
> jUdQUstCMWXK/IJNMRYuaavm/c76bYxtOlrsjgv6HfXoQ8z0+mj/lwduS3GkNdvG
> bL6QEWL5sgXIPmlbPWdATeslb/G+5zOVp2HygLhXoP92L5b2w+5Io5iWfBeJ9yUG
> Xn6J5uxGBjyS5TQoYDQeNaTyuIqebPPxhsgCeEdKBKBr6D1kbfrZHc9MmiGXhDhh
> jMpL/lQ7Wq3BcxUZYQe1MR4vn2sdm1p5tHtnAgI4xRylIyvRliSZiljMW8kwsB5S
> 6/TaLJSjJeo5TVTWtzdgI8LUbWPnYm1i021DKQPbqQzI0sSwTfFrbZgzFiIQzmL/
> P4geRABA49TliHvwpUpf77DgC9U04O9bpoSM1Lzg3CTrQyANOOz5qj+S2MKLGcKU
> irJgGPI+rrbHqBBuUGUOV4Lgi/+QSycyZ/JxuJZMONyWf0MjjCl4TkqB34atLHzP
> xxrqe+hcronSYmz561xFNoUO3aaDtVo2gyG6eN9uEo/uH64N5Ob3B3Tw6fmQqNO2
> bz1U6waurp3QDuUBYdGT1zGL0bm7MSAAGrGEi+ZBTvPRENLlh1zw8H3bSYT9uO6S
> LAQNs2GzvmREr7VuGqrceQ6C8K16B41gifo6rJGVByrr+JGlCfjFtGs5k6z0dbSo
> Ug6m2Fx3aWaOpnXjlmmI
> =36Ss
> -END PGP SIGNATURE-
>
> ___
> Chicken-users mailing list
> Chicken-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] generate numerical list

2016-07-11 Thread Jeremy Steward

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Note that iota annoyingly does not work well with the numbers egg ->
it cannot figure out what an exact rational should be. So:

~ (use srfi-1 numbers)
~ (iota 1 10 (/ 3 2))

outputs:

~ Error: (iota) bad argument type - not a number: 3/2

Instead, you could define your own `iota` procedure after importing
the numbers egg using `unfold`, or you could define something like
MATLAB's `linspace`:

~ (define (my-iota count #!optional (start 0) (step 1))
~   (unfold (lambda (x) (>= (/ (- x start) step) count))
~   (lambda (x) x)
~   (lambda (x) (+ x step))
~   start))

~ (define (linspace base limit n)
~   (unfold (lambda (x) (> x limit))
~   (lambda (x) x)
~   (lambda (x) (+ x (/ (- limit base)
~   (- n 1
~   base))

~ (linspace 1 10 10) ;=> (1 2 3 4 5 6 7 8 9 10)
~ (linspace 0 50 5)  ;=> (0 25/2 25 75/2 50)

I'm sure I'm omitting some error checking in the above (for sequences
that would end up infinite), but it should get you on the right track
if you do find that SRFI-1 does not suffice when using exact rationals.

Regards,

On 11/07/16 08:21 PM, Evan Hanson wrote:
| Hi Jinsong,
|
| SRFI-1 provides `iota' -- http://api.call-cc.org/doc/srfi-1/iota
|
| Cheers,
|
| Evan
|
| ___ Chicken-users
| mailing list Chicken-users@nongnu.org
| https://lists.nongnu.org/mailman/listinfo/chicken-users
|

- -- 
Jeremy Steward



-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCAAGBQJXhFlbAAoJEKflx7ZMcbY7zIoQAJnzUGexanBT0TbCv+si8ikG
jUdQUstCMWXK/IJNMRYuaavm/c76bYxtOlrsjgv6HfXoQ8z0+mj/lwduS3GkNdvG
bL6QEWL5sgXIPmlbPWdATeslb/G+5zOVp2HygLhXoP92L5b2w+5Io5iWfBeJ9yUG
Xn6J5uxGBjyS5TQoYDQeNaTyuIqebPPxhsgCeEdKBKBr6D1kbfrZHc9MmiGXhDhh
jMpL/lQ7Wq3BcxUZYQe1MR4vn2sdm1p5tHtnAgI4xRylIyvRliSZiljMW8kwsB5S
6/TaLJSjJeo5TVTWtzdgI8LUbWPnYm1i021DKQPbqQzI0sSwTfFrbZgzFiIQzmL/
P4geRABA49TliHvwpUpf77DgC9U04O9bpoSM1Lzg3CTrQyANOOz5qj+S2MKLGcKU
irJgGPI+rrbHqBBuUGUOV4Lgi/+QSycyZ/JxuJZMONyWf0MjjCl4TkqB34atLHzP
xxrqe+hcronSYmz561xFNoUO3aaDtVo2gyG6eN9uEo/uH64N5Ob3B3Tw6fmQqNO2
bz1U6waurp3QDuUBYdGT1zGL0bm7MSAAGrGEi+ZBTvPRENLlh1zw8H3bSYT9uO6S
LAQNs2GzvmREr7VuGqrceQ6C8K16B41gifo6rJGVByrr+JGlCfjFtGs5k6z0dbSo
Ug6m2Fx3aWaOpnXjlmmI
=36Ss
-END PGP SIGNATURE-

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


Re: [Chicken-users] generate numerical list

2016-07-11 Thread Jinsong Liang
Exactly what I need. Thank you Evan!

Jinsong

On Mon, Jul 11, 2016 at 10:21 PM, Evan Hanson  wrote:

> Hi Jinsong,
>
> SRFI-1 provides `iota' -- http://api.call-cc.org/doc/srfi-1/iota
>
> Cheers,
>
> Evan
>
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] generate numerical list

2016-07-11 Thread Evan Hanson
Hi Jinsong,

SRFI-1 provides `iota' -- http://api.call-cc.org/doc/srfi-1/iota

Cheers,

Evan

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


[Chicken-users] generate numerical list

2016-07-11 Thread Jinsong Liang
Hi,

Is there an existing API  to generate a list of numbers, given start value,
end value, and step?

For example, given 1, 2, and 0.5, a list of (1, 1.5, 2) is returned.

Thank you!

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


Re: [Chicken-users] Generating C

2016-07-11 Thread Norman Gray


Greetings.

A followup...

On 8 Jul 2016, at 19:46, Norman Gray wrote:

"/Data/tools/chicken-4.11.0/bin/csc" -t -unit db -optimize-level 3 
-include-path ../.. -emit-all-import-libraries -output-file db.c 
../../db.scm



[...]
[panic] nursery is too small - try higher setting using the `-:s' 
option - execution terminated



Error: shell command terminated with non-zero exit status 256: 
'/Data/tools/chicken-4.11.0/bin/chicken' '../../db.scm' -output-file 
'db.c' -unit db -optimize-level 3 -include-path ../.. 
-emit-all-import-libraries


This seems to have fixed itself, without me doing anything I'm aware of 
to fix it.


It _appears_ to be something to do with module resolution, even though 
the error message is '[panic] nursery is too small' rather than anything 
about imports.  I suspect that because when I was trying to work out 
what was going on, I was as a side-effect re-generating other modules.  
I therefore can't reproduce the problem.


So I can now generate .c files.  I can't compile them (more module 
resolution problems), but I can generate them.


The documentation at 
 is perhaps a 
trifle laconic, and saying 'This is naturally rather simplistic' 
doesn't really fill in the blanks.


One useful thing to mention on that page would be that when compiling 
modules, '-t -unit ' is necessary, otherwise we get 
(intelligible in eventual retrospect) duplicate symbols when 
compiling.  Inspection of c-backend.scm solved that particular puzzle.


The build system, based on Makefile.* and *.make files, seems quite 
narrowly targeted for the case of building Chicken itself.  The 
experiments I've tried suggest that it can be adapted to building an 
assembly of .c files, when I get them, but it needs a bit of hacking 
for that case, and feels a bit wild-west.  Is that really the 
recommended technique?


It would be seriously useful if chicken-install, for example, could 
work out the recursive set of dependencies for a particular source 
file, and print them in a reusable way.  I wrote quite a lot of a tool 
to do this, and to generate a Makefile which would assemble a kit and 
prepare to build it.  However it started to acquire more and more 
special cases, and it became clear that it could never really work 
reliably, given the freedom of action afforded to the contents of 
.setup.  Given that chicken-install already has to deal with this 
complication, would it be reasonable for it to gain an option to emit 
the dependencies, ideally in the form of a Makefile?


I still have the impression that the ability to generate distributable 
C is a key feature of Chicken (is this true?), which makes it odd that 
this is documented only in a few dozen lines at the bottom of the 
'Using the compiler' page, and odd that an apparently simple build -- 
I'm not doing anything exotic -- is quite this difficult, and requires 
quite so much use of the source (Luke).  Have I (as happens so often) 
got the wrong end of the stick?


Best wishes,

Norman


--
Norman Gray  :  https://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

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