Last change
on this file since 19028 was
19028,
checked in by Kon Lovett, 11 years ago

Export Schemeish uni, etc. & argumentsX routines

File size:
997 bytes

Line  

1  ;;;; argumentshelpers.inc 

2  ;;;; Kon Lovett, Jul '10 

3  

4  ;;; Helpers 

5  

6  (defineinline (chainrecur fns xs) 

7  ; assume the length of fns is << so recursion depth is also << 

8  (let recur ((fns fns)) 

9  (if (null? fns) xs 

10  (apply (car fns) (recur (cdr fns))) ) ) ) 

11  

12  (defineinline (chainfunc fns) 

13  (cond 

14  ((null? fns) 

15  identity ) 

16  ((null? (cdr fns)) 

17  (let ((f (car fns))) 

18  (lambda (xs) (apply f xs)) ) ) 

19  (else 

20  (lambda (xs) (chainrecur fns xs)) ) ) ) 

21  

22  (defineinline (eachfunc fns) 

23  (cond 

24  ((null? fns) 

25  identity ) 

26  ((null? (cdr fns)) 

27  (let ((f (car fns))) 

28  (lambda (xs) (map (cut f <>) xs)) ) ) 

29  (else 

30  (let ((fns (apply circularlist fns))) 

31  (lambda (xs) (map (cut <> <>) fns xs)) ) ) ) ) 

32  

33  (defineinline (allfunc fns) 

34  (cond 

35  ((null? fns) 

36  identity ) 

37  ((null? (cdr fns)) 

38  (let ((f (car fns))) 

39  (lambda (xs) (list (apply f xs))) ) ) 

40  (else 

41  (lambda (xs) (map (cut apply <> xs) fns)) ) ) ) 

Note: See
TracBrowser
for help on using the repository browser.