aboutsummaryrefslogtreecommitdiff
path: root/src/boot/strap/utility.clisp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-12-28 04:03:36 +0000
committerdos-reis <gdr@axiomatics.org>2011-12-28 04:03:36 +0000
commit1fd6a63bbce9234ba3b8efa12c9a91643f0a87a1 (patch)
tree49569695e13334db4bf2c15f769c6761173f7db3 /src/boot/strap/utility.clisp
parent8165b0668e5116e9ed43b9de15bf961792598d72 (diff)
downloadopen-axiom-1fd6a63bbce9234ba3b8efa12c9a91643f0a87a1.tar.gz
* boot/tokens.boot: Do not rewrite drop and take.
* boot/utility.boot (drop): Define and export. (take): Likewise. * interp/br-con.boot: Use take, not TAKE; use drop, not DROP. * interp/br-data.boot: Likewise. * interp/br-op1.boot: Likewise. * interp/br-saturn.boot: Likewise. * interp/c-doc.boot: Likewise. * interp/c-util.boot: Likewise. * interp/cattable.boot: Likewise. * interp/clammed.boot: Likewise. * interp/compiler.boot: Likewise. * interp/database.boot: Likewise. * interp/define.boot: Likewise. * interp/guess.boot: Likewise. * interp/htsetvar.boot: Likewise. * interp/i-analy.boot: Likewise. * interp/i-eval.boot: Likewise. * interp/i-funsel.boot: Likewise. * interp/i-map.boot: Likewise. * interp/i-output.boot: Likewise. * interp/i-special.boot: Likewise. * interp/i-syscmd.boot: Likewise. * interp/i-toplev.boot: Likewise. * interp/i-util.boot: Likewise. * interp/nruncomp.boot: Likewise. * interp/parse.boot: Likewise. * interp/record.boot: Likewise. * interp/setvars.boot: Likewise. * interp/slam.boot: Likewise. * interp/trace.boot: Likewise. * interp/word.boot: Likewise. * interp/macros.lisp (DROP): Remove. (TAKE): Likewise.
Diffstat (limited to 'src/boot/strap/utility.clisp')
-rw-r--r--src/boot/strap/utility.clisp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/boot/strap/utility.clisp b/src/boot/strap/utility.clisp
index 73e14218..83ee8844 100644
--- a/src/boot/strap/utility.clisp
+++ b/src/boot/strap/utility.clisp
@@ -21,7 +21,7 @@
|substitute!| |setDifference| |setUnion| |setIntersection|
|symbolAssoc| |applySubst| |applySubst!| |applySubstNQ|
|objectAssoc| |remove| |removeSymbol| |atomic?| |every?|
- |any?| |takeWhile| |copyTree| |finishLine|)))
+ |any?| |take| |takeWhile| |drop| |copyTree| |finishLine|)))
(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Thing|) |%Thing|) |substitute|))
@@ -83,11 +83,17 @@
|any?|))
(DECLAIM
+ (FTYPE (FUNCTION (|%Short| (|%List| |%Thing|)) (|%List| |%Thing|)) |take|))
+
+(DECLAIM
(FTYPE
(FUNCTION ((FUNCTION (|%Thing|) |%Thing|) (|%List| |%Thing|))
(|%List| |%Thing|))
|takeWhile|))
+(DECLAIM
+ (FTYPE (FUNCTION (|%Short| (|%List| |%Thing|)) (|%List| |%Thing|)) |drop|))
+
(DECLAIM (FTYPE (FUNCTION (|%Thing|) |%Thing|) |copyTree|))
(DECLAIM (FTYPE (FUNCTION (|%Thing|) |%Void|) |finishLine|))
@@ -120,6 +126,26 @@
(COND (|bfVar#2| (RETURN |bfVar#2|)))))
(SETQ |bfVar#1| (CDR |bfVar#1|)))))
+(DEFUN |take| (|n| |l|)
+ (COND
+ ((NOT (MINUSP |n|))
+ (LET ((|bfVar#3| NIL)
+ (|bfVar#4| NIL)
+ (|bfVar#1| |l|)
+ (|x| NIL)
+ (|bfVar#2| 1))
+ (LOOP
+ (COND
+ ((OR (NOT (CONSP |bfVar#1|)) (PROGN (SETQ |x| (CAR |bfVar#1|)) NIL)
+ (> |bfVar#2| |n|))
+ (RETURN |bfVar#3|))
+ ((NULL |bfVar#3|) (SETQ |bfVar#3| #1=(CONS |x| NIL))
+ (SETQ |bfVar#4| |bfVar#3|))
+ (T (RPLACD |bfVar#4| #1#) (SETQ |bfVar#4| (CDR |bfVar#4|))))
+ (SETQ |bfVar#1| (CDR |bfVar#1|))
+ (SETQ |bfVar#2| (+ |bfVar#2| 1)))))
+ (T (|drop| (+ (LENGTH |l|) |n|) |l|))))
+
(DEFUN |takeWhile| (|f| |l|)
(LET ((|bfVar#2| NIL) (|bfVar#3| NIL) (|bfVar#1| |l|) (|x| NIL))
(LOOP
@@ -132,6 +158,17 @@
(T (RPLACD |bfVar#3| #1#) (SETQ |bfVar#3| (CDR |bfVar#3|))))
(SETQ |bfVar#1| (CDR |bfVar#1|)))))
+(DEFUN |drop| (|n| |l|)
+ (COND
+ ((NOT (MINUSP |n|))
+ (LOOP
+ (COND
+ ((NOT (AND (PLUSP |n|) (CONSP |l|) (PROGN (SETQ |l| (CDR |l|)) T)))
+ (RETURN NIL))
+ (T (SETQ |n| (- |n| 1)))))
+ |l|)
+ (T (|take| (+ (LENGTH |l|) |n|) |l|))))
+
(DEFUN |copyTree| (|t|)
(COND ((CONSP |t|) (CONS (|copyTree| (CAR |t|)) (|copyTree| (CDR |t|))))
(T |t|)))