aboutsummaryrefslogtreecommitdiff
path: root/functions.lisp
blob: 8296f87b02dcc7e7afe3fb06cfde7884806d9e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
;;;; lambda-tools.lisp

(in-package #:lambda-riffs)

(defun -> (arg &rest fns)
  (dolist (fn fns arg)
    (setf arg (funcall fn arg))))

(defun all> (arg &rest preds)
  "Predicate Filter. Returns ARG if (PRED ARG) is non-NIL for every
PRED in PREDS"
  (dolist (pred preds arg)
    (unless (funcall pred arg)
      (return-from all> nil))))


(defun some> (arg &rest preds)
  "Predicate filter. Returns ARG if (PRED ARG) is non-NIL for any PRED
in PREDS."
  (dolist (pred preds nil)
    (when (funcall pred arg)
      (return-from some> arg))))


(defun <> (&rest fns)
  (lambda (arg)
    (apply #'>> arg fns)))