From cac1778bd0bd1668e3c67301e07ce743fe912802 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 30 Oct 2009 14:14:24 -0500 Subject: [PATCH] remove most uses of roll/-roll from extra --- extra/bunny/model/model.factor | 9 ++++++--- extra/math/quadratic/quadratic.factor | 8 +++----- extra/spider/unique-deque/unique-deque.factor | 13 +++++++------ extra/synth/synth.factor | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/extra/bunny/model/model.factor b/extra/bunny/model/model.factor index d80f3aa98a..b9923d5976 100755 --- a/extra/bunny/model/model.factor +++ b/extra/bunny/model/model.factor @@ -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 ; diff --git a/extra/math/quadratic/quadratic.factor b/extra/math/quadratic/quadratic.factor index 60929b92cb..e4642a863b 100644 --- a/extra/math/quadratic/quadratic.factor +++ b/extra/math/quadratic/quadratic.factor @@ -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 * + ; diff --git a/extra/spider/unique-deque/unique-deque.factor b/extra/spider/unique-deque/unique-deque.factor index b4bbc9fbf8..9003b56b15 100644 --- a/extra/spider/unique-deque/unique-deque.factor +++ b/extra/spider/unique-deque/unique-deque.factor @@ -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 diff --git a/extra/synth/synth.factor b/extra/synth/synth.factor index be1e5943af..def610d356 100644 --- a/extra/synth/synth.factor +++ b/extra/synth/synth.factor @@ -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 >>data ; + [ sample-freq>> * >integer 0 ] [ (>>data) ] [ ] tri ; TUPLE: harmonic n amplitude ; C: harmonic @@ -32,5 +32,5 @@ C: note harmonic amplitude>> ; : >note ( harmonics note buffer -- buffer ) - dup -roll [ note-harmonic-data ] 2curry map >>data ; + [ [ note-harmonic-data ] 2curry map ] [ (>>data) ] [ ] tri ; -- 2.34.1