Updated some of the typed benchmarks.
This commit is contained in:
parent
e90e37ec62
commit
fb09e9da23
|
@ -1,5 +1,6 @@
|
|||
;;; NQUEENS -- Compute number of solutions to 8-queens problem.
|
||||
;; 2006/08 -- renamed `try' to `try-it' to avoid Bigloo collision (mflatt)
|
||||
;; 2010/04 -- got rid of the one-armed id (stamourv)
|
||||
|
||||
(module nqueens-typed typed/scheme
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
;;; PARAFFINS -- Compute how many paraffins exist with N carbon atoms.
|
||||
|
||||
(module paraffins-typed typed/scheme
|
||||
#lang typed/scheme/base
|
||||
|
||||
(define-type Radical (Rec Radical (U 'C 'H 'BCP 'CCP (Vectorof Radical))))
|
||||
(require/typed scheme/base (collect-garbage ( -> Void)))
|
||||
|
||||
(: gen (Integer -> (Vectorof (Listof Radical))))
|
||||
(define (gen n)
|
||||
(define-type Radical (Rec Radical (U 'C 'H 'BCP 'CCP (Vectorof Radical))))
|
||||
|
||||
(: gen (Integer -> (Vectorof (Listof Radical))))
|
||||
(define (gen n)
|
||||
(let*: ((n/2 : Integer (quotient n 2))
|
||||
(radicals : (Vectorof (Listof Radical)) (make-vector (+ n/2 1) '(H))))
|
||||
|
||||
|
@ -145,8 +147,8 @@
|
|||
(vector-set! radicals i (rads-of-size i))
|
||||
(loop (+ i 1)))))))
|
||||
|
||||
(: three-partitions (Integer -> (Listof (Vectorof Integer))))
|
||||
(define (three-partitions m)
|
||||
(: three-partitions (Integer -> (Listof (Vectorof Integer))))
|
||||
(define (three-partitions m)
|
||||
(let: loop1 : (Listof (Vectorof Integer))
|
||||
((lst : (Listof (Vectorof Integer)) '())
|
||||
(nc1 : Integer (quotient m 3)))
|
||||
|
@ -160,8 +162,8 @@
|
|||
(loop2 (cons (vector nc1 nc2 (- m (+ nc1 nc2))) lst)
|
||||
(- nc2 1)))))))
|
||||
|
||||
(: four-partitions (Integer -> (Listof (Vectorof Integer))))
|
||||
(define (four-partitions m)
|
||||
(: four-partitions (Integer -> (Listof (Vectorof Integer))))
|
||||
(define (four-partitions m)
|
||||
(let: loop1 : (Listof (Vectorof Integer))
|
||||
((lst : (Listof (Vectorof Integer)) '())
|
||||
(nc1 : Integer (quotient m 4)))
|
||||
|
@ -180,13 +182,13 @@
|
|||
(loop3 (cons (vector nc1 nc2 nc3 (- m (+ nc1 (+ nc2 nc3)))) lst)
|
||||
(- nc3 1))))))))))
|
||||
|
||||
(: nb (Integer -> Integer))
|
||||
(define (nb n)
|
||||
(: nb (Integer -> Integer))
|
||||
(define (nb n)
|
||||
(let ((x (gen n)))
|
||||
(+ (length (vector-ref x 0))
|
||||
(length (vector-ref x 1)))))
|
||||
|
||||
(let ((input (with-input-from-file "input.txt" read)))
|
||||
(let ((input (with-input-from-file "input.txt" read)))
|
||||
(time
|
||||
(let: loop : Integer
|
||||
((n : Integer 100) (v : Integer 0))
|
||||
|
@ -194,4 +196,3 @@
|
|||
v
|
||||
(loop (- n 1) (nb (if input 17 0)))))))
|
||||
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user