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
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 ;
! 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@ ;
: +- ( 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 * + ;
! 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 ;
: 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
[ 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
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 ;