]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorSam Anklesaria <sam@Tintin.local>
Tue, 26 May 2009 21:32:34 +0000 (16:32 -0500)
committerSam Anklesaria <sam@Tintin.local>
Tue, 26 May 2009 21:32:34 +0000 (16:32 -0500)
1  2 
core/sequences/sequences.factor
core/vocabs/parser/parser.factor

index fd04b5f8f7591111dff3fc78da48d8da046d48aa,36e4c95470be53f40283065ee776d67dbe5a8043..20a94f411a79507120c1323cd3ae24935f2e36bf
@@@ -1,6 -1,6 +1,6 @@@
  ! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
  ! See http://factorcode.org/license.txt for BSD license.
 -USING: accessors kernel kernel.private slots.private math
 +USING: accessors kernel kernel.private locals slots.private math
  math.private math.order ;
  IN: sequences
  
@@@ -626,7 -626,7 +626,7 @@@ PRIVATE
          [ 0 swap copy ] keep
      ] new-like ;
  
- : peek ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
+ : last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
  
  : pop* ( seq -- ) [ length 1 - ] [ shorten ] bi ;
  
@@@ -821,7 -821,7 +821,7 @@@ PRIVATE
      [ rest ] [ first-unsafe ] bi ;
  
  : unclip-last ( seq -- butlast last )
-     [ but-last ] [ peek ] bi ;
+     [ but-last ] [ last ] bi ;
  
  : unclip-slice ( seq -- rest-slice first )
      [ rest-slice ] [ first-unsafe ] bi ; inline
@@@ -852,7 -852,7 +852,7 @@@ PRIVATE
      [ find-last ] (map-find) ; inline
  
  : unclip-last-slice ( seq -- butlast-slice last )
-     [ but-last-slice ] [ peek ] bi ; inline
+     [ but-last-slice ] [ last ] bi ; inline
  
  : <flat-slice> ( seq -- slice )
      dup slice? [ { } like ] when
@@@ -931,14 -931,3 +931,14 @@@ PRIVATE
              [ array-flip ] [ generic-flip ] if
          ] [ generic-flip ] if
      ] unless ;
 +
 +: reduce1 ( seq quot -- result ) [ unclip ] dip reduce ; inline
 +
 +:: reduce-r
 +    ( list identity quot: ( obj1 obj2 -- obj ) -- result )
 +    list empty?
 +    [ identity ]
 +    [ list rest identity quot reduce-r list first quot call ] if ;
 +    inline recursive
 +
 +:: combos ( list1 list2 -- result ) list2 [ [ 2array ] curry list1 swap map ] map concat ;
index b071a378bc61f515743e298f640be1ab2bfb4a32,ca783c13e6ada1c01aa4c2c9e53ccf6161881f36..5305b42809ccdf59a053d93c9ab487001ac553c8
@@@ -6,7 -6,7 +6,7 @@@ sets strings vocabs sorting accessors a
  combinators vectors splitting continuations math
  parser.notes ;
  IN: vocabs.parser
 -
 + 
  ERROR: no-word-error name ;
  
  : word-restarts ( possibilities -- restarts )
@@@ -17,7 -17,7 +17,7 @@@
      word-restarts
      swap "Defer word in current vocabulary" swap 2array
      suffix ;
 -
 + 
  : <no-word-error> ( name possibilities -- error restarts )
      [ drop \ no-word-error boa ] [ word-restarts-with-defer ] 2bi ;
  
@@@ -193,7 -193,7 +193,7 @@@ TUPLE: ambiguous-use-error words 
  
  : qualified-search ( name manifest -- word/f )
      qualified-vocabs>>
-     (vocab-search) 0 = [ drop f ] [ peek ] if ;
+     (vocab-search) 0 = [ drop f ] [ last ] if ;
  
  PRIVATE>
  
      2dup qualified-search dup [ 2nip ] [ drop vocab-search ] if ;
  
  : search ( name -- word/f )
 -    manifest get search-manifest ;
 +    manifest get search-manifest ;