]> gitweb.factorcode.org Git - factor.git/commitdiff
Use [ max ] map-reduce instead of map supremum; would be nice to find a good name...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 2 Feb 2009 09:46:10 +0000 (03:46 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 2 Feb 2009 09:46:10 +0000 (03:46 -0600)
basis/alien/structs/structs.factor
basis/compiler/tree/normalization/introductions/introductions.factor
basis/stack-checker/branches/branches.factor
basis/tools/disassembler/udis/udis.factor
extra/project-euler/008/008.factor
extra/project-euler/011/011.factor
extra/project-euler/056/056.factor
extra/sequences/modified/modified.factor
extra/tetris/tetromino/tetromino.factor

index a3c616cda2d8dee7f4d162357af8ead626e8f23c..42923fb28bbe475565eb7097479f701cb3a7b22b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays generic hashtables kernel kernel.private
 math namespaces parser sequences strings words libc fry
-alien.c-types alien.structs.fields cpu.architecture ;
+alien.c-types alien.structs.fields cpu.architecture math.order ;
 IN: alien.structs
 
 TUPLE: struct-type size align fields ;
@@ -47,7 +47,7 @@ M: struct-type stack-size
     [ first2 <field-spec> ] with with map ;
 
 : compute-struct-align ( types -- n )
-    [ c-type-align ] map supremum ;
+    [ c-type-align ] [ max ] map-reduce ;
 
 : define-struct ( name vocab fields -- )
     [
@@ -59,5 +59,5 @@ M: struct-type stack-size
 
 : define-union ( name members -- )
     [ expand-constants ] map
-    [ [ heap-size ] map supremum ] keep
+    [ [ heap-size ] [ max ] map-reduce ] keep
     compute-struct-align f (define-struct) ;
index 9e96dc0472846dcd1018492d3fc267160cec9653..743b8c56da8827dc050a06a988937f03c645f1b1 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces sequences accessors math kernel
-compiler.tree ;
+compiler.tree math.order ;
 IN: compiler.tree.normalization.introductions
 
 SYMBOL: introductions
@@ -25,7 +25,7 @@ M: #introduce count-introductions*
 
 M: #branch count-introductions*
     children>>
-    [ count-introductions ] map supremum
+    [ count-introductions ] [ max ] map-reduce
     introductions+ ;
 
 M: #recursive count-introductions*
index 2eb4fb46a9f0ab2f6e67e7302fa210fc1ae346eb..690af39c28cc2bf645b7859073f5f587a893fb16 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fry vectors sequences assocs math accessors kernel
+USING: fry vectors sequences assocs math math.order accessors kernel
 combinators quotations namespaces grouping stack-checker.state
 stack-checker.backend stack-checker.errors stack-checker.visitor
 stack-checker.values stack-checker.recursive-state ;
@@ -16,7 +16,7 @@ SYMBOL: +bottom+
 
 : pad-with-bottom ( seq -- newseq )
     dup empty? [
-        dup [ length ] map supremum
+        dup [ length ] [ max ] map-reduce
         '[ _ +bottom+ pad-head ] map
     ] unless ;
 
index cb52b1d5dbf80f611db285773bd464328c734375..cfa2483c7e7e50f24bbab5a5ae1aea0d06f968d4 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: tools.disassembler namespaces combinators
 alien alien.syntax alien.c-types lexer parser kernel
-sequences layouts math math.parser system make fry arrays ;
+sequences layouts math math.order
+math.parser system make fry arrays ;
 IN: tools.disassembler.udis
 
 <<
@@ -56,7 +57,7 @@ SINGLETON: udis-disassembler
 : buf/len ( from to -- buf len ) [ drop <alien> ] [ swap - ] 2bi ;
 
 : format-disassembly ( lines -- lines' )
-    dup [ second length ] map supremum
+    dup [ second length ] [ max ] map-reduce
     '[
         [
             [ first >hex cell 2 * CHAR: 0 pad-head % ": " % ]
index 24ccbb443a8bdb83d4b2b3a844366ed5fe2f4a04..1e8dade646d603ff2460d6c879ba7572f8b2889c 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: grouping math.parser sequences ;
+USING: grouping math.order math.parser sequences ;
 IN: project-euler.008
 
 ! http://projecteuler.net/index.php?section=problems&id=8
@@ -64,7 +64,7 @@ IN: project-euler.008
 PRIVATE>
 
 : euler008 ( -- answer )
-    source-008 5 clump [ string>digits product ] map supremum ;
+    source-008 5 clump [ string>digits product ] [ max ] map-reduce ;
 
 ! [ euler008 ] 100 ave-time
 ! 2 ms ave run time - 0.79 SD (100 trials)
index 094069572684b34e1944549d14ea78a557cdac34..122eec2c2e6904c1dfc6a9cf7fb38b98e0d6aea0 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: grouping kernel make sequences ;
+USING: grouping kernel make math.order sequences ;
 IN: project-euler.011
 
 ! http://projecteuler.net/index.php?section=problems&id=11
@@ -88,7 +88,7 @@ IN: project-euler.011
 
 : max-product ( matrix width -- n )
     [ clump ] curry map concat
-    [ product ] map supremum ; inline
+    [ product ] [ max ] map-reduce ; inline
 
 PRIVATE>
 
index 34626b796d8de38d202b2dc184f9f420755917e3..4e7bbdc0df1979c417e5ff8d8af7262968fbcb1e 100644 (file)
@@ -23,7 +23,7 @@ IN: project-euler.056
 
 : euler056 ( -- answer )
     90 100 [a,b) dup cartesian-product
-    [ first2 ^ number>digits sum ] map supremum ;
+    [ first2 ^ number>digits sum ] [ max ] map-reduce ;
 
 ! [ euler056 ] 100 ave-time
 ! 22 ms ave run time - 2.13 SD (100 trials)
index 3e4c1b1bdc3d14719d80acba9a295e1544f91ec1..d552f2dc77a9ede9af6930d911df60a5a9146eb4 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel math sequences sequences.private shuffle ;
+USING: accessors arrays kernel math math.order
+sequences sequences.private shuffle ;
 IN: sequences.modified
 
 TUPLE: modified ;
@@ -50,7 +51,7 @@ M: offset modified-set-nth ( elt n seq -- )
 TUPLE: summed < modified seqs ;
 C: <summed> summed
 
-M: summed length seqs>> [ length ] map supremum ;
+M: summed length seqs>> [ length ] [ max ] map-reduce ;
 
 <PRIVATE
 : ?+ ( x/f y/f -- sum )
index 7e6b2ecf341943555e300101986b9b4cae689d76..127e4854e0d569a8bd5292e6fe76d38ab594fb41 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel arrays namespaces sequences math math.vectors
-colors random ;
+USING: kernel arrays namespaces sequences math math.order
+math.vectors colors random ;
 IN: tetris.tetromino
 
 TUPLE: tetromino states colour ;
@@ -104,7 +104,7 @@ SYMBOL: tetrominoes
     tetrominoes get random ;
 
 : blocks-max ( blocks quot -- max )
-    map [ 1+ ] map supremum ; inline
+    map [ 1+ ] [ max ] map-reduce ; inline
 
 : blocks-width ( blocks -- width )
     [ first ] blocks-max ;