]> gitweb.factorcode.org Git - factor.git/commitdiff
remove most uses of roll/-roll from extra
authorJoe Groff <arcata@gmail.com>
Fri, 30 Oct 2009 19:14:24 +0000 (14:14 -0500)
committerJoe Groff <arcata@gmail.com>
Fri, 30 Oct 2009 19:14:24 +0000 (14:14 -0500)
extra/bunny/model/model.factor
extra/math/quadratic/quadratic.factor
extra/spider/unique-deque/unique-deque.factor
extra/synth/synth.factor

index d80f3aa98aa6f00f2d5461c7b86a72d7a0f2a337..b9923d5976cf74149eb920d749bb79cf11b4b842 100755 (executable)
@@ -1,6 +1,6 @@
 USING: accessors alien.c-types arrays combinators destructors
 http.client io io.encodings.ascii io.files io.files.temp kernel
-math math.matrices math.parser math.vectors opengl
+locals math math.matrices math.parser math.vectors opengl
 opengl.capabilities opengl.gl opengl.demo-support sequences
 splitting vectors words specialized-arrays ;
 QUALIFIED-WITH: alien.c-types c
@@ -51,8 +51,11 @@ IN: bunny.model
         over download-to
     ] unless ;
 
-: (draw-triangle) ( ns vs triple -- )
-    [ dup roll nth gl-normal swap nth gl-vertex ] with with each ;
+:: (draw-triangle) ( ns vs triple -- )
+    triple [| elt |
+        elt ns nth gl-normal
+        elt vs nth gl-vertex
+    ] each ;
 
 : draw-triangles ( ns vs is -- )
     GL_TRIANGLES [ [ (draw-triangle) ] with with each ] do-state ;
index 60929b92cb543b63e442b291c424c4c5a669e306..e4642a863b4e4d4e6606b674ecd467b2d7201518 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions ;
+USING: kernel locals math math.functions ;
 IN: math.quadratic
 
 : monic ( c b a -- c' b' ) tuck [ / ] 2bi@ ;
@@ -12,9 +12,7 @@ IN: math.quadratic
 : +- ( x y -- x+y x-y ) [ + ] [ - ] 2bi ;
 
 : quadratic ( c b a -- alpha beta )
-    #! Solve a quadratic equation ax^2 + bx + c = 0
     monic discriminant critical +- ;
 
-: qeval ( x c b a -- y )
-    #! Evaluate ax^2 + bx + c
-    [ pick * ] dip roll sq * + + ;
+:: qeval ( x c b a -- y )
+    c b x * + a x sq * + ;
index b4bbc9fbf8a5f5566f30189420940803bd0220ba..9003b56b15939e64f90c8b864cfd9c14fed76d9a 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs deques dlists kernel ;
+USING: accessors assocs deques dlists kernel locals ;
 IN: spider.unique-deque
 
 TUPLE: todo-url url depth ;
@@ -30,8 +30,9 @@ TUPLE: unique-deque assoc deque ;
 
 : peek-url ( unique-deque -- todo-url ) deque>> peek-front ;
 
-: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
-    pick deque-empty? [ 3drop ] [
-        [ [ pop-front dup ] 2dip [ call ] dip [ t ] compose [ drop f ] if ]
-        [ roll [ slurp-deque-when ] [ 3drop ] if ] 3bi
-    ] if ; inline recursive
+:: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
+    deque deque-empty? [
+        deque pop-front dup quot1 call
+        [ quot2 call t ] [ drop f ] if
+        [ deque quot1 quot2 slurp-deque-when ] when
+    ] unless ; inline recursive
index be1e5943afc7dbf7f025cf06ffb1de5c2d37b25d..def610d356527d1d795470b0be2256b4a13a0c34 100644 (file)
@@ -16,7 +16,7 @@ MEMO: single-sine-wave ( samples/wave -- seq )
     [ sample-freq>> -rot sine-wave ] keep swap >>data ;
 
 : >silent-buffer ( seconds buffer -- buffer )
-    tuck sample-freq>> * >integer 0 <repetition> >>data ;
+    [ sample-freq>> * >integer 0 <repetition> ] [ (>>data) ] [ ] tri ;
 
 TUPLE: harmonic n amplitude ;
 C: <harmonic> harmonic
@@ -32,5 +32,5 @@ C: <note> note
     harmonic amplitude>> <scaled> ;
 
 : >note ( harmonics note buffer -- buffer )
-    dup -roll [ note-harmonic-data ] 2curry map <summed> >>data ;
+    [ [ note-harmonic-data ] 2curry map <summed> ] [ (>>data) ] [ ] tri ;