~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to sigscheme/bench/bench-cpstak.scm

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
2
; File:         cpstak.sch
 
3
; Description:  continuation-passing version of TAK
 
4
; Author:       Will Clinger
 
5
; Created:      20-Aug-87
 
6
; Language:     Scheme
 
7
; Status:       Public Domain
 
8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
9
 
 
10
;;; CPSTAK -- A continuation-passing version of the TAK benchmark.
 
11
;;; A good test of first class procedures and tail recursion.
 
12
 
 
13
(define (cpstak x y z)
 
14
  (define (tak x y z k)
 
15
    (if (not (< y x))
 
16
        (k z)
 
17
        (tak (- x 1)
 
18
             y
 
19
             z
 
20
             (lambda (v1)
 
21
               (tak (- y 1)
 
22
                    z
 
23
                    x
 
24
                    (lambda (v2)
 
25
                      (tak (- z 1)
 
26
                           x
 
27
                           y
 
28
                           (lambda (v3)
 
29
                             (tak v1 v2 v3 k)))))))))
 
30
  (tak x y z (lambda (a) a)))
 
31
 
 
32
(cpstak 18 12 6)
 
33
 
 
34
;;; (run-benchmark "CPSTAK" (lambda () (cpstak 18 12 6)))