[Chicken-users] Re: crazy behaviour in csi!

2005-12-06 Thread Jens Axel Søgaard

Sunnan wrote:

Thanks, I guess I was stressed, and forgot that unknown macros can
already be defined. The error message just looked so weird.

I was pretty sleep-deprived at the time.

I hadn't looked at srfi-31 before. I thought I knew most of the srfis.
This one was pretty disappointing.

(define (...) 10)
; They want to write:
((rec (F N) 
  (if (zero? N) 1 
	  (* N (F (- N 1) (...))


;; instead of:
(let f ((n (...)))
  (if (zero? n) 1
  (* n (f (- n 1)
;; it's the exact same number of characters!


Almost - note that REC returns the recursive
function, so you need to return the function
in the let:

  ((let f ((n (...)))
 (if (zero? n) 1
 (* n (f (- n 1
 f)
(...))

--
Jens Axel Søgaard






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


[Chicken-users] Re: Better algorithm for growing hash tables

2005-12-06 Thread Eric Hanchrow
I too am suffering from very slow hash tables.  I'm brand-new to
chicken (although not to scheme) so it's possible that I'm doing
something wrong.

The gist of the problem is: I'm using bignums (from the numbers)
extension as the hash table key; I created the table with
(make-hash-table =); I'm reading lines from /usr/share/dict/words, and
for each line, I'm computing a number, and using that number as the
hash key, and the word as the value.

It starts out storing perhaps 300 words per second, then gets
progressively slower; as I write this, it's storing perhaps 30 words
per second (the hash table has about 34,000 entries).

I'm using version 212 (which I got from darcs), so I expect all the
patches that have been previously mentioned have already been applied.

I'm happy to make the code available if anyone's interested (it's
small).

Any ideas how I can speed this up?
-- 
Paul Graham is right.
--Shriram Krishnamurthi



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


the point of REC , was (Re: [Chicken-users] Re: crazy behaviour in csi!)

2005-12-06 Thread Sunnan
On Mon, 2005-12-05 at 23:54 +0100, Jens Axel Søgaard wrote:
 Sunnan wrote:
  ;; instead of:
  (let f ((n (...)))
(if (zero? n) 1
(* n (f (- n 1)
  ;; it's the exact same number of characters!
 
 Almost - note that REC returns the recursive
 function, so you need to return the function
 in the let:
 
((let f ((n (...)))
   (if (zero? n) 1
   (* n (f (- n 1
   f)
  (...))

But that does the same thing; the whole expression as such returns the
result of the recursive function in both cases. The recursive function
returned by REC is use-once-and-destroy.
And in chicken, 
((rec (F N) 
  (if (zero? N) 1 
  (* N (F (- N 1) (...))

macroexpands to almost the same as 

(let f ((n (...)))
  (if (zero? n) 1
  (* n (f (- n 1)

if I recall correctly.
BTW, your example evaluates (...) twice.
AML,
Sunnan



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