From: Joe Groff Date: Fri, 30 Oct 2009 22:11:45 +0000 (-0500) Subject: exile roll and -roll to basis/shuffle and mark them deprecated X-Git-Tag: 0.97~4971^2~17 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=3f15e028f7e2f962b33fca8693ea527784be0949 exile roll and -roll to basis/shuffle and mark them deprecated --- diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 4c96ed4000..e401f85f6e 100755 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -4,7 +4,7 @@ USING: accessors cpu.architecture vocabs.loader system sequences namespaces parser kernel kernel.private classes classes.private arrays hashtables vectors classes.tuple sbufs hashtables.private sequences.private math classes.tuple.private -growable namespaces.private assocs words command-line vocabs io +growable namespaces.private shuffle assocs words command-line vocabs io io.encodings.string libc splitting math.parser memory compiler.units math.order quotations quotations.private assocs.private ; FROM: compiler => enable-optimizer ; diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index 3a0fada735..32f5750cd3 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private quotations classes classes.algebra classes.tuple.private continuations growable namespaces hints alien.accessors compiler.tree.builder compiler.tree.optimizer sequences.deep -compiler definitions generic.single ; +compiler definitions generic.single shuffle ; IN: compiler.tests.optimizer GENERIC: xyz ( obj -- obj ) @@ -446,4 +446,4 @@ M: object bad-dispatch-position-test* ; [ 1024 bignum ] [ 10 [ 1 >bignum swap >fixnum shift ] compile-call dup class ] unit-test ! Not sure if I want to fix this... -! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with \ No newline at end of file +! [ t [ [ f ] [ 3 ] if >fixnum ] compile-call ] [ no-method? ] must-fail-with diff --git a/basis/compiler/tree/dead-code/dead-code-tests.factor b/basis/compiler/tree/dead-code/dead-code-tests.factor index ed4df91eec..d859096e1d 100644 --- a/basis/compiler/tree/dead-code/dead-code-tests.factor +++ b/basis/compiler/tree/dead-code/dead-code-tests.factor @@ -6,7 +6,7 @@ compiler.tree.tuple-unboxing compiler.tree.debugger compiler.tree.recursive compiler.tree.normalization compiler.tree.checker tools.test kernel math stack-checker.state accessors combinators io prettyprint words sequences.deep -sequences.private arrays classes kernel.private ; +sequences.private arrays classes kernel.private shuffle ; IN: compiler.tree.dead-code.tests : count-live-values ( quot -- n ) diff --git a/basis/shuffle/shuffle-docs.factor b/basis/shuffle/shuffle-docs.factor new file mode 100644 index 0000000000..15398450a7 --- /dev/null +++ b/basis/shuffle/shuffle-docs.factor @@ -0,0 +1,5 @@ +USING: help.markup help.syntax ; +IN: shuffle + +HELP: roll $complex-shuffle ; +HELP: -roll $complex-shuffle ; diff --git a/basis/shuffle/shuffle-tests.factor b/basis/shuffle/shuffle-tests.factor index e091af2d06..4165efdcfd 100644 --- a/basis/shuffle/shuffle-tests.factor +++ b/basis/shuffle/shuffle-tests.factor @@ -1,5 +1,10 @@ USING: shuffle tools.test ; +IN: shuffle.tests [ 1 2 3 4 ] [ 3 4 1 2 2swap ] unit-test [ 4 2 3 ] [ 1 2 3 4 shuffle( a b c d -- d b c ) ] unit-test + +[ 2 3 4 1 ] [ 1 2 3 4 roll ] unit-test +[ 1 2 3 4 ] [ 2 3 4 1 -roll ] unit-test + diff --git a/basis/shuffle/shuffle.factor b/basis/shuffle/shuffle.factor index 079e81d082..43c0b75be1 100644 --- a/basis/shuffle/shuffle.factor +++ b/basis/shuffle/shuffle.factor @@ -22,6 +22,10 @@ MACRO: shuffle-effect ( effect -- ) SYNTAX: shuffle( ")" parse-effect suffix! \ shuffle-effect suffix! ; +: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated + +: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated + : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline : 4dup ( a b c d -- a b c d a b c d ) 4 ndup ; inline diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index b837c0a3ff..f7ae292630 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -27,8 +27,6 @@ HELP: -rot ( x y z -- z x y ) $complex-shuffle ; HELP: dupd ( x y -- x x y ) $complex-shuffle ; HELP: swapd ( x y z -- y x z ) $complex-shuffle ; HELP: tuck ( x y -- y x y ) $complex-shuffle ; -HELP: roll $complex-shuffle ; -HELP: -roll $complex-shuffle ; HELP: datastack ( -- ds ) { $values { "ds" array } } @@ -280,11 +278,6 @@ HELP: 3bi "[ p ] [ q ] 3bi" "3dup p q" } - "If " { $snippet "[ p ]" } " and " { $snippet "[ q ]" } " have stack effect " { $snippet "( x y z -- w )" } ", then the following two lines are equivalent:" - { $code - "[ p ] [ q ] 3bi" - "3dup p -roll q" - } "In general, the following two lines are equivalent:" { $code "[ p ] [ q ] 3bi" @@ -835,8 +828,6 @@ $nl swapd rot -rot - roll - -roll spin } ; diff --git a/core/kernel/kernel-tests.factor b/core/kernel/kernel-tests.factor index 024254663c..d9babb5fd7 100644 --- a/core/kernel/kernel-tests.factor +++ b/core/kernel/kernel-tests.factor @@ -48,9 +48,6 @@ IN: kernel.tests [ -7 ] must-fail -[ 2 3 4 1 ] [ 1 2 3 4 roll ] unit-test -[ 1 2 3 4 ] [ 2 3 4 1 -roll ] unit-test - [ 3 ] [ t 3 and ] unit-test [ f ] [ f 3 and ] unit-test [ f ] [ 3 f and ] unit-test diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 6538109687..22c96c4318 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -10,10 +10,6 @@ DEFER: 3dip ! Stack stuff : spin ( x y z -- z y x ) swap rot ; inline -: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline - -: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline - : 2over ( x y z -- x y z x y ) pick pick ; inline : clear ( -- ) { } set-datastack ; @@ -63,9 +59,9 @@ DEFER: if : dip ( x quot -- x ) swap [ call ] dip ; -: 2dip ( x y quot -- x y ) -rot [ call ] 2dip ; +: 2dip ( x y quot -- x y ) swap [ dip ] dip ; -: 3dip ( x y z quot -- x y z ) -roll [ call ] 3dip ; +: 3dip ( x y z quot -- x y z ) swap [ 2dip ] dip ; : 4dip ( w x y z quot -- w x y z ) swap [ 3dip ] dip ; inline diff --git a/extra/reports/noise/noise.factor b/extra/reports/noise/noise.factor index cae2c20877..9eb2804b42 100755 --- a/extra/reports/noise/noise.factor +++ b/extra/reports/noise/noise.factor @@ -10,7 +10,6 @@ IN: reports.noise : badness ( word -- n ) H{ { -nrot 5 } - { -roll 4 } { -rot 3 } { bi@ 1 } { 2curry 1 } @@ -54,7 +53,6 @@ IN: reports.noise { nwith 4 } { over 2 } { pick 4 } - { roll 4 } { rot 3 } { spin 3 } { swap 1 } diff --git a/extra/sudokus/sudokus.factor b/extra/sudokus/sudokus.factor index 9de9a6fe7c..ff20f15204 100644 --- a/extra/sudokus/sudokus.factor +++ b/extra/sudokus/sudokus.factor @@ -2,7 +2,7 @@ USING: accessors arrays combinators.short-circuit grouping kernel lists lists.lazy locals math math.functions math.parser math.ranges models.product monads random sequences sets ui ui.gadgets.controls ui.gadgets.layout models.combinators ui.gadgets.alerts vectors fry -ui.gadgets.labels ; +ui.gadgets.labels shuffle ; IN: sudokus : row ( index -- row ) 1 + 9 / ceiling ; @@ -37,4 +37,4 @@ IN: sudokus ] with-self , ] { 280 220 } >>pref-dim "Sudoku Sleuth" open-window ] with-ui ; -MAIN: do-sudoku \ No newline at end of file +MAIN: do-sudoku