remove most uses of roll/-roll from extra

db4
Joe Groff 2009-10-30 14:14:24 -05:00
parent 2bc75e390a
commit cac1778bd0
4 changed files with 18 additions and 16 deletions

View File

@ -1,6 +1,6 @@
USING: accessors alien.c-types arrays combinators destructors USING: accessors alien.c-types arrays combinators destructors
http.client io io.encodings.ascii io.files io.files.temp kernel 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 opengl.capabilities opengl.gl opengl.demo-support sequences
splitting vectors words specialized-arrays ; splitting vectors words specialized-arrays ;
QUALIFIED-WITH: alien.c-types c QUALIFIED-WITH: alien.c-types c
@ -51,8 +51,11 @@ IN: bunny.model
over download-to over download-to
] unless ; ] unless ;
: (draw-triangle) ( ns vs triple -- ) :: (draw-triangle) ( ns vs triple -- )
[ dup roll nth gl-normal swap nth gl-vertex ] with with each ; triple [| elt |
elt ns nth gl-normal
elt vs nth gl-vertex
] each ;
: draw-triangles ( ns vs is -- ) : draw-triangles ( ns vs is -- )
GL_TRIANGLES [ [ (draw-triangle) ] with with each ] do-state ; GL_TRIANGLES [ [ (draw-triangle) ] with with each ] do-state ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2007 Slava Pestov. ! Copyright (C) 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.functions ; USING: kernel locals math math.functions ;
IN: math.quadratic IN: math.quadratic
: monic ( c b a -- c' b' ) tuck [ / ] 2bi@ ; : monic ( c b a -- c' b' ) tuck [ / ] 2bi@ ;
@ -12,9 +12,7 @@ IN: math.quadratic
: +- ( x y -- x+y x-y ) [ + ] [ - ] 2bi ; : +- ( x y -- x+y x-y ) [ + ] [ - ] 2bi ;
: quadratic ( c b a -- alpha beta ) : quadratic ( c b a -- alpha beta )
#! Solve a quadratic equation ax^2 + bx + c = 0
monic discriminant critical +- ; monic discriminant critical +- ;
: qeval ( x c b a -- y ) :: qeval ( x c b a -- y )
#! Evaluate ax^2 + bx + c c b x * + a x sq * + ;
[ pick * ] dip roll sq * + + ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2009 Doug Coleman. ! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! 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 IN: spider.unique-deque
TUPLE: todo-url url depth ; TUPLE: todo-url url depth ;
@ -30,8 +30,9 @@ TUPLE: unique-deque assoc deque ;
: peek-url ( unique-deque -- todo-url ) deque>> peek-front ; : peek-url ( unique-deque -- todo-url ) deque>> peek-front ;
: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- ) :: slurp-deque-when ( deque quot1 quot2: ( value -- ) -- )
pick deque-empty? [ 3drop ] [ deque deque-empty? [
[ [ pop-front dup ] 2dip [ call ] dip [ t ] compose [ drop f ] if ] deque pop-front dup quot1 call
[ roll [ slurp-deque-when ] [ 3drop ] if ] 3bi [ quot2 call t ] [ drop f ] if
] if ; inline recursive [ deque quot1 quot2 slurp-deque-when ] when
] unless ; inline recursive

View File

@ -16,7 +16,7 @@ MEMO: single-sine-wave ( samples/wave -- seq )
[ sample-freq>> -rot sine-wave ] keep swap >>data ; [ sample-freq>> -rot sine-wave ] keep swap >>data ;
: >silent-buffer ( seconds buffer -- buffer ) : >silent-buffer ( seconds buffer -- buffer )
tuck sample-freq>> * >integer 0 <repetition> >>data ; [ sample-freq>> * >integer 0 <repetition> ] [ (>>data) ] [ ] tri ;
TUPLE: harmonic n amplitude ; TUPLE: harmonic n amplitude ;
C: <harmonic> harmonic C: <harmonic> harmonic
@ -32,5 +32,5 @@ C: <note> note
harmonic amplitude>> <scaled> ; harmonic amplitude>> <scaled> ;
: >note ( harmonics note buffer -- buffer ) : >note ( harmonics note buffer -- buffer )
dup -roll [ note-harmonic-data ] 2curry map <summed> >>data ; [ [ note-harmonic-data ] 2curry map <summed> ] [ (>>data) ] [ ] tri ;