Aziz,

So I keep some of those little combinators in separate libraries.

Here's the time for a version which imports 'bi' and 'uni' from a separate library:

~ # ikarus --r6rs-script /scratch/_fib-fp-dharmalab-a.scm
running stats for (fib 34):
    no collections
    1376 ms elapsed cpu time, including 0 ms collecting
    1389 ms elapsed real time, including 0 ms collecting
    0 bytes allocated
~ #

vs the version when they're in the same library:

~ # ikarus --r6rs-script /scratch/_fib-fp-a.scm
running stats for (fib 34):
    no collections
    336 ms elapsed cpu time, including 0 ms collecting
    358 ms elapsed real time, including 0 ms collecting
    0 bytes allocated

Any more tricks up your sleeve? :-)

The actual 'dharmalab' libraries are at:

    http://github.com/dharmatech/dharmalab

By the way, perhaps 'time' should show the 'cp0-size-limit' and 'optimize-level' so that you don't have to guess (or ask) users when they submit timing information.

Ed

----------------------------------------------------------------------
(import (rnrs)
        (dharmalab combinators concatenative)
        (ikarus))

(define (sub x)
  (lambda (y)
    (- y x)))

(define (constant x)
  (lambda (y)
    x))

(define (ifte f g h)
  (lambda (x)
    (if (f x)
        (g x)
        (h x))))

(define (less-than= x)
  (lambda (y)
    (<= y x)))

(define fib
  (ifte (less-than= 1)
        (constant 1)
        (bi (uni (sub 1) (lambda (x) (fib x)))
            (uni (sub 2) (lambda (x) (fib x))) +)))

(time (fib 34))
----------------------------------------------------------------------

Reply via email to