From 76da2a6e786348aca9afa7952cf7f407d6042101 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sat, 29 Nov 2014 17:10:54 -0800 Subject: [PATCH] match: rename ?1-tail to ?rest. --- basis/match/match.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/match/match.factor b/basis/match/match.factor index bd1bf9e930..c9745a1055 100644 --- a/basis/match/match.factor +++ b/basis/match/match.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. ! ! Based on pattern matching code from Paul Graham's book 'On Lisp'. -USING: parser lexer kernel words namespaces make sequences -classes.tuple combinators macros assocs math effects ; +USING: assocs classes.tuple combinators kernel lexer macros make +math namespaces parser sequences words ; IN: match SYMBOL: _ @@ -65,13 +65,13 @@ MACRO: match-cond ( assoc -- ) [ match [ "Pattern does not match" throw ] unless* ] dip swap [ replace-patterns ] with-variables ; -: ?1-tail ( seq -- tail/f ) - dup length zero? not [ rest ] [ drop f ] if ; +: ?rest ( seq -- tailseq/f ) + [ f ] [ rest ] if-empty ; : (match-first) ( seq pattern-seq -- bindings leftover/f ) 2dup shorter? [ 2drop f f ] [ 2dup length head over match - [ swap ?1-tail ] [ [ rest ] dip (match-first) ] ?if + [ swap ?rest ] [ [ rest ] dip (match-first) ] ?if ] if ; : match-first ( seq pattern-seq -- bindings )