Changeset 37001 in project


Ignore:
Timestamp:
12/16/18 17:59:16 (6 months ago)
Author:
kon
Message:

forgot pl-solver, xC shuffle

Location:
release/5/amb
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/amb/trunk/amb.egg

    r36214 r37001  
    33
    44((synopsis "The non-deterministic backtracking ambivalence operator")
    5  (version "3.0.0")
     5 (version "3.0.1")
    66 (category data)
    77 (author "[[thomas chust]]")
  • release/5/amb/trunk/amb.scm

    r36233 r37001  
    3939;;; data-structures
    4040
    41 (: shuffle ((list-of *) (procedure (fixnum) fixnum) -> (list-of *)))
    42 ;
    43 (define (shuffle ls #!optional (rand pseudo-random-integer))
     41(cond-expand
     42  (chicken-5
     43    (import
     44      (only (chicken fixnum) fx<)
     45      (only (chicken random) pseudo-random-integer)
     46      (only (chicken sort) sort!)
     47      (only (srfi 1) map!))
     48    (define platform-random pseudo-random-integer) )
     49  (chicken-4
     50    (use
     51      chicken
     52      (only extras random)
     53      (only data-structures sort!)
     54      (only (srfi 1) map!))
     55    (define platform-random random) ) )
     56
     57(: fx<car ((pair fixnum *) (pair fixnum *) --> boolean))
     58;
     59(define (fx<car a b) (fx< (car a) (car b)))
     60
     61(: shuffle ((list-of *) #!optional (procedure (fixnum) fixnum) -> (list-of *)))
     62;
     63(define (shuffle ls #!optional (rand platform-random))
    4464  (let* (
    4565    (len (length ls))
    4666    (tagged-ls (map (lambda (x) (cons (rand len) x)) ls)) )
    47     (map! cdr (sort! tagged-ls (lambda (a b) (fx< (car a) (car b)))) ) ) )
     67    (map! cdr (sort! tagged-ls fx<car) ) ) )
    4868
    4969;;; miscmacros
Note: See TracChangeset for help on using the changeset viewer.