Changeset 35142 in project


Ignore:
Timestamp:
02/17/18 19:30:34 (10 months ago)
Author:
kon
Message:

use typed-define

Location:
release/4/amb/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/amb/trunk/amb-extras.scm

    r35102 r35142  
    2424  (only data-structures sort! constantly)
    2525  (only (srfi 1) count every)
    26   amb)
     26  amb
     27  typed-define)
    2728
    2829;;;
     
    8283;;
    8384
    84 (define (count-member x xs #!optional (eql? equal?))
    85   (count (cut eql? x <>) xs) )
     85(define: (count-member (x *) (xs (list-of *)) . (opts (list procedure))) --> fixnum
     86  (let ((eql? (optional opts equal?)))
     87    (count (cut eql? x <>) xs) ) )
    8688
    87 (define (only-member? x xs #!optional (eql? equal?))
    88   (= 1 (count-member x xs eql?)) )
     89(define: (only-member? (x *) (xs (list-of *)) . (opts (list procedure))) --> boolean
     90  (let ((eql? (optional opts equal?)))
     91    (= 1 (count-member x xs eql?)) ) )
    8992
    9093;;
    9194
    92 (define (list-constantly ls)
     95(define: (list-constantly (ls list)) --> (list-of procedure)
    9396  (map constantly ls) )
    9497
    9598;;
    9699
    97 (define (distinct? xs #!optional (eql? equal?))
    98   (every (cut only-member? <> xs eql?) xs) )
     100(define: (distinct? (xs (list-of *)) . (opts (list procedure))) --> boolean
     101  (let ((eql? (optional opts equal?)))
     102    (every (cut only-member? <> xs eql?) xs) ) )
    99103
    100104) ;module amb-extras
  • release/4/amb/trunk/amb.meta

    r35102 r35142  
    1111        (miscmacros "2.91")
    1212        (check-errors "1.12.0")
    13         (condition-utils "1.0.0"))
     13        (condition-utils "1.0.0")
     14        (dsssl-utils "2.1.0"))
    1415 (test-depends test)
    1516 (files
  • release/4/amb/trunk/amb.scm

    r35102 r35142  
    2929  (only miscmacros let/cc define-parameter)
    3030  (only type-errors warning-argument-type)
    31   (only condition-utils make-exn-condition+))
     31  (only condition-utils make-exn-condition+)
     32  typed-define)
    3233
    3334;;;
     
    104105;;
    105106
    106 (define (amb-thunks thunks)
     107(define: (amb-thunks (thunks (list-of procedure))) -> *
    107108  (let ((afc (amb-failure-continuation)))
    108109    (let/cc return
     
    116117            (return ((car tt))) ) ) ) ) ) )
    117118
    118 (define (amb-thunks-shuffled thunks #!optional (rand (amb-random-function)))
    119   (amb-thunks (shuffle thunks rand)) )
     119(define: (amb-thunks-shuffled (thunks (list-of procedure)) . (opts (list procedure))) -> *
     120  (let ((rand (optional opts (amb-random-function))))
     121    (amb-thunks (shuffle thunks rand)) ) )
    120122
    121 (define (amb-find-thunk thunk #!optional (failure amb-exhausted))
    122   (let/cc return
    123     (let ((fail-k (lambda () (return (failure)))))
    124       (parameterize ((amb-failure-continuation fail-k))
    125         (thunk) ) ) ) )
     123(define: (amb-find-thunk (thunk procedure) . (opts (list procedure))) -> *
     124  (let ((failure (optional opts amb-exhausted)))
     125    (let/cc return
     126      (let ((fail-k (lambda () (return (failure)))))
     127        (parameterize ((amb-failure-continuation fail-k))
     128          (thunk) ) ) ) ) )
    126129
    127 (define (amb-collect-thunk thunk)
     130(define: (amb-collect-thunk (thunk procedure)) -> *
    128131  (let ((afc #f))
    129132    (dynamic-wind
     
    148151;;;
    149152
    150 (define (shuffle ls random)
     153(define: (shuffle (ls (list-of *)) (random procedure)) -> (list-of *)
    151154  ;
    152155  (define (car< x y)
Note: See TracChangeset for help on using the changeset viewer.