Merge branch 'master' of git://factorcode.org/git/factor
commit
8c4fb753f6
|
@ -1,11 +1,11 @@
|
||||||
USING: io.streams.string csv tools.test shuffle kernel strings
|
USING: io.streams.string csv tools.test kernel strings
|
||||||
io.pathnames io.files.unique io.encodings.utf8 io.files
|
io.pathnames io.files.unique io.encodings.utf8 io.files
|
||||||
io.directories ;
|
io.directories ;
|
||||||
IN: csv.tests
|
IN: csv.tests
|
||||||
|
|
||||||
! I like to name my unit tests
|
! I like to name my unit tests
|
||||||
: named-unit-test ( name output input -- )
|
: named-unit-test ( name output input -- )
|
||||||
nipd unit-test ; inline
|
unit-test drop ; inline
|
||||||
|
|
||||||
! tests nicked from the wikipedia csv article
|
! tests nicked from the wikipedia csv article
|
||||||
! http://en.wikipedia.org/wiki/Comma-separated_values
|
! http://en.wikipedia.org/wiki/Comma-separated_values
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: arrays continuations db io kernel math namespaces
|
USING: arrays continuations db io kernel math namespaces
|
||||||
quotations sequences db.postgresql.ffi alien alien.c-types
|
quotations sequences db.postgresql.ffi alien alien.c-types
|
||||||
db.types tools.walker ascii splitting math.parser combinators
|
db.types tools.walker ascii splitting math.parser combinators
|
||||||
libc shuffle calendar.format byte-arrays destructors prettyprint
|
libc calendar.format byte-arrays destructors prettyprint
|
||||||
accessors strings serialize io.encodings.binary io.encodings.utf8
|
accessors strings serialize io.encodings.binary io.encodings.utf8
|
||||||
alien.strings io.streams.byte-array summary present urls
|
alien.strings io.streams.byte-array summary present urls
|
||||||
specialized-arrays.uint specialized-arrays.alien db.private ;
|
specialized-arrays.uint specialized-arrays.alien db.private ;
|
||||||
|
@ -117,7 +117,7 @@ M: postgresql-result-null summary ( obj -- str )
|
||||||
|
|
||||||
: pq-get-string ( handle row column -- obj )
|
: pq-get-string ( handle row column -- obj )
|
||||||
3dup PQgetvalue utf8 alien>string
|
3dup PQgetvalue utf8 alien>string
|
||||||
dup empty? [ [ pq-get-is-null f ] dip ? ] [ 3nip ] if ;
|
dup empty? [ [ pq-get-is-null f ] dip ? ] [ [ 3drop ] dip ] if ;
|
||||||
|
|
||||||
: pq-get-number ( handle row column -- obj )
|
: pq-get-number ( handle row column -- obj )
|
||||||
pq-get-string dup [ string>number ] when ;
|
pq-get-string dup [ string>number ] when ;
|
||||||
|
@ -134,7 +134,7 @@ M: postgresql-malloc-destructor dispose ( obj -- )
|
||||||
: pq-get-blob ( handle row column -- obj/f )
|
: pq-get-blob ( handle row column -- obj/f )
|
||||||
[ PQgetvalue ] 3keep 3dup PQgetlength
|
[ PQgetvalue ] 3keep 3dup PQgetlength
|
||||||
dup 0 > [
|
dup 0 > [
|
||||||
3nip
|
[ 3drop ] dip
|
||||||
[
|
[
|
||||||
memory>byte-array >string
|
memory>byte-array >string
|
||||||
0 <uint>
|
0 <uint>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays kernel make math math.order math.vectors sequences shuffle
|
USING: arrays kernel make math math.order math.vectors sequences
|
||||||
splitting vectors ;
|
splitting vectors ;
|
||||||
IN: math.polynomials
|
IN: math.polynomials
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ PRIVATE>
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: pgcd ( p q -- a d )
|
: pgcd ( p q -- a d )
|
||||||
swap V{ 0 } clone V{ 1 } clone 2swap (pgcd) [ >array ] bi@ ;
|
[ V{ 0 } clone V{ 1 } clone ] 2dip swap (pgcd) [ >array ] bi@ ;
|
||||||
|
|
||||||
: pdiff ( p -- p' )
|
: pdiff ( p -- p' )
|
||||||
dup length v* { 0 } ?head drop ;
|
dup length v* { 0 } ?head drop ;
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs combinators kernel math
|
USING: accessors assocs combinators kernel math
|
||||||
quotations sequences regexp.parser regexp.classes fry arrays
|
quotations sequences regexp.parser regexp.classes fry arrays
|
||||||
combinators.short-circuit regexp.utils prettyprint regexp.nfa
|
combinators.short-circuit regexp.utils prettyprint regexp.nfa ;
|
||||||
shuffle ;
|
|
||||||
IN: regexp.traversal
|
IN: regexp.traversal
|
||||||
|
|
||||||
TUPLE: dfa-traverser
|
TUPLE: dfa-traverser
|
||||||
|
@ -170,7 +169,7 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
|
||||||
] [ drop ] if ;
|
] [ drop ] if ;
|
||||||
|
|
||||||
: match-default ( transition from-state table -- to-state/f )
|
: match-default ( transition from-state table -- to-state/f )
|
||||||
nipd transitions>> at t swap at ;
|
[ drop ] 2dip transitions>> at t swap at ;
|
||||||
|
|
||||||
: match-transition ( obj from-state dfa -- to-state/f )
|
: match-transition ( obj from-state dfa -- to-state/f )
|
||||||
{ [ match-literal ] [ match-class ] [ match-default ] } 3|| ;
|
{ [ match-literal ] [ match-class ] [ match-default ] } 3|| ;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
USING: shuffle tools.test ;
|
USING: shuffle tools.test ;
|
||||||
|
|
||||||
[ 8 ] [ 5 6 7 8 3nip ] unit-test
|
|
||||||
[ 3 1 2 3 ] [ 1 2 3 tuckd ] unit-test
|
|
||||||
[ 1 2 3 4 ] [ 3 4 1 2 2swap ] unit-test
|
[ 1 2 3 4 ] [ 3 4 1 2 2swap ] unit-test
|
||||||
|
|
|
@ -6,14 +6,6 @@ IN: shuffle
|
||||||
|
|
||||||
: 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
|
: 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
|
||||||
|
|
||||||
: nipd ( a b c -- b c ) rot drop ; inline
|
|
||||||
|
|
||||||
: 3nip ( a b c d -- d ) 3 nnip ; inline
|
|
||||||
|
|
||||||
: 4nip ( a b c d e -- e ) 4 nnip ; inline
|
|
||||||
|
|
||||||
: 4dup ( a b c d -- a b c d a b c d ) 4 ndup ; inline
|
: 4dup ( a b c d -- a b c d a b c d ) 4 ndup ; inline
|
||||||
|
|
||||||
: 4drop ( a b c d -- ) 3drop drop ; inline
|
: 4drop ( a b c d -- ) 3drop drop ; inline
|
||||||
|
|
||||||
: tuckd ( x y z -- z x y z ) 2 ntuck ; inline
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (c) 2007, 2008 Aaron Schaefer, Alexander Solovyov, Vishal Talwar.
|
! Copyright (c) 2007, 2008 Aaron Schaefer, Alexander Solovyov, Vishal Talwar.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math sequences shuffle ;
|
USING: kernel math sequences ;
|
||||||
IN: project-euler.002
|
IN: project-euler.002
|
||||||
|
|
||||||
! http://projecteuler.net/index.php?section=problems&id=2
|
! http://projecteuler.net/index.php?section=problems&id=2
|
||||||
|
@ -41,7 +41,7 @@ PRIVATE>
|
||||||
! -------------------
|
! -------------------
|
||||||
|
|
||||||
: fib-upto* ( n -- seq )
|
: fib-upto* ( n -- seq )
|
||||||
0 1 [ pick over >= ] [ tuck + dup ] [ ] produce 3nip
|
0 1 [ pick over >= ] [ tuck + dup ] [ ] produce [ 3drop ] dip
|
||||||
but-last-slice { 0 1 } prepend ;
|
but-last-slice { 0 1 } prepend ;
|
||||||
|
|
||||||
: euler002a ( -- answer )
|
: euler002a ( -- answer )
|
||||||
|
|
|
@ -25,7 +25,6 @@ IN: reports.noise
|
||||||
{ 3drop 1 }
|
{ 3drop 1 }
|
||||||
{ 3dup 2 }
|
{ 3dup 2 }
|
||||||
{ 3keep 3 }
|
{ 3keep 3 }
|
||||||
{ 3nip 4 }
|
|
||||||
{ 3slip 3 }
|
{ 3slip 3 }
|
||||||
{ 4drop 2 }
|
{ 4drop 2 }
|
||||||
{ 4dup 3 }
|
{ 4dup 3 }
|
||||||
|
@ -50,7 +49,6 @@ IN: reports.noise
|
||||||
{ ndrop 2 }
|
{ ndrop 2 }
|
||||||
{ ndup 3 }
|
{ ndup 3 }
|
||||||
{ nip 2 }
|
{ nip 2 }
|
||||||
{ nipd 3 }
|
|
||||||
{ nkeep 5 }
|
{ nkeep 5 }
|
||||||
{ npick 6 }
|
{ npick 6 }
|
||||||
{ nrot 5 }
|
{ nrot 5 }
|
||||||
|
@ -66,7 +64,6 @@ IN: reports.noise
|
||||||
{ swap 1 }
|
{ swap 1 }
|
||||||
{ swapd 3 }
|
{ swapd 3 }
|
||||||
{ tuck 2 }
|
{ tuck 2 }
|
||||||
{ tuckd 4 }
|
|
||||||
{ with 1/2 }
|
{ with 1/2 }
|
||||||
|
|
||||||
{ bi 1/2 }
|
{ bi 1/2 }
|
||||||
|
|
Loading…
Reference in New Issue