parse-command-line
- H{ } clone changed-words set-global
+ all-words [ dup ] H{ } map>assoc changed-words set-global
"-no-crossref" cli-args member? [
"Cross-referencing..." print flush
] if
[
- ! Compile everything if compiler is loaded
- all-words [ changed-word ] each
-
"exclude" "include"
[ get-global " " split [ empty? not ] subset ] 2apply
seq-diff
"/\\" member? ;
: path+ ( str1 str2 -- str )
- >r [ path-separator? ] rtrim r>
- [ path-separator? ] ltrim
- >r "/" r> 3append ;
+ >r [ path-separator? ] right-trim "/" r>
+ [ path-separator? ] left-trim 3append ;
: stat ( path -- directory? permissions length modified )
normalize-pathname (stat) ;
[ -1./0. 0 delete-nth ] unit-test-fails
[ "" ] [ "" [ blank? ] trim ] unit-test
-[ "" ] [ "" [ blank? ] ltrim ] unit-test
-[ "" ] [ "" [ blank? ] rtrim ] unit-test
+[ "" ] [ "" [ blank? ] left-trim ] unit-test
+[ "" ] [ "" [ blank? ] right-trim ] unit-test
+[ "" ] [ " " [ blank? ] left-trim ] unit-test
+[ "" ] [ " " [ blank? ] right-trim ] unit-test
[ "asdf" ] [ " asdf " [ blank? ] trim ] unit-test
-[ "asdf " ] [ " asdf " [ blank? ] ltrim ] unit-test
-[ " asdf" ] [ " asdf " [ blank? ] rtrim ] unit-test
+[ "asdf " ] [ " asdf " [ blank? ] left-trim ] unit-test
+[ " asdf" ] [ " asdf " [ blank? ] right-trim ] unit-test
dup slice? [ { } like ] when 0 over length rot <slice> ;
inline
-: ltrim ( seq quot -- newseq )
- over >r [ not ] compose find drop
- r> swap [ tail ] when* ; inline
+: left-trim ( seq quot -- newseq )
+ over >r [ not ] compose find drop r> swap
+ [ tail ] [ dup length tail ] if* ; inline
-: rtrim ( seq quot -- newseq )
- over >r [ not ] compose find-last drop
- r> swap [ 1+ head ] when* ; inline
+: right-trim ( seq quot -- newseq )
+ over >r [ not ] compose find-last drop r> swap
+ [ 1+ head ] [ 0 head ] if* ; inline
: trim ( seq quot -- newseq )
- [ ltrim ] keep rtrim ; inline
+ [ left-trim ] keep right-trim ; inline
: sum ( seq -- n ) 0 [ + ] reduce ;
: product ( seq -- n ) 1 [ * ] reduce ;
! http://www.ffconsultancy.com/free/ray_tracer/languages.html
USING: float-arrays compiler generic io io.files kernel math
-math.vectors math.parser namespaces sequences
+math.functions math.vectors math.parser namespaces sequences
sequences.private words ;
IN: benchmark.raytracer
! Factor port of
! http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnorm&lang=all
-USING: float-arrays kernel math math.vectors sequences
-sequences.private prettyprint words tools.time hints ;
+USING: float-arrays kernel math math.functions math.vectors
+sequences sequences.private prettyprint words tools.time hints ;
IN: benchmark.spectral-norm
: fast-truncate >fixnum >float ; inline
USING: kernel namespaces
math
+ math.functions
math.vectors
math.parser
hashtables sequences threads
! See http://factorcode.org/license.txt for BSD license.
USING: arrays hashtables io io.streams.string kernel math
-math.vectors math.parser
+math.vectors math.functions math.parser
namespaces sequences strings tuples system ;
IN: calendar
! Copyright (C) 2006, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.parser models sequences ui ui.gadgets
-ui.gadgets.controls ui.gadgets.frames ui.gadgets.labels
-ui.gadgets.packs ui.gadgets.sliders ui.render ;
+USING: kernel math math.functions math.parser models sequences
+ui ui.gadgets ui.gadgets.controls ui.gadgets.frames
+ui.gadgets.labels ui.gadgets.packs ui.gadgets.sliders ui.render
+;
IN: color-picker
! Simple example demonstrating the use of models.
! Copyright (C) 2007 Eduardo Cavazos
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel combinators arrays sequences math combinators.lib ;
+USING: kernel combinators arrays sequences math math.functions
+combinators.lib ;
IN: colors.hsv
: file>sha1 ( file -- sha1 ) <file-reader> stream>sha1 ;
: string>sha1-interleave ( string -- )
- [ zero? ] ltrim
+ [ zero? ] left-trim
dup length odd? [ 1 tail ] when
seq>2seq [ string>sha1 ] 2apply
swap 2seq>seq ;
-USING: kernel combinators sequences math math.vectors mortar slot-accessors
+USING: kernel combinators sequences math math.functions math.vectors mortar slot-accessors
x x.widgets.wm.root x.widgets.wm.frame combinators.lib ;
IN: factory.commands
dup first CHAR: \\ = [ CHAR: \\ , ] unless %
] "" make
] }
- } cond [ "/\\." member? ] rtrim ;
+ } cond [ "/\\." member? ] right-trim ;
SYMBOL: io-hash
destructor-obj closesocket drop ;
M: windows-io root-directory? ( path -- ? )
- [ path-separator? ] rtrim
+ [ path-separator? ] right-trim
dup length 2 = [
dup first Letter?
swap second CHAR: : = and
SYMBOL: irc-client
: irc-stream> ( -- stream ) irc-client get irc-client-stream ;
-: trim-: ( seq -- seq ) [ CHAR: : = ] ltrim ;
+: trim-: ( seq -- seq ) [ CHAR: : = ] left-trim ;
: parse-name ( string -- string )
trim-: "!" split first ;
: irc-split ( string -- seq )
: odd ( seq -- seq ) 2 group 1 <column> ;
DEFER: fft
: two ( seq -- seq ) fft 2 v/n dup append ;
-: omega ( n -- n ) recip -2 pi i * * * exp ;
+: omega ( n -- n ) recip -2 pi i* * * exp ;
: twiddle ( seq -- seq ) dup length dup omega swap n^v v* ;
: (fft) ( seq -- seq ) dup odd two twiddle swap even two v+ ;
: fft ( seq -- seq ) dup length 1 = [ (fft) ] unless ;
: p= ( p p -- ? ) pextend = ;
: ptrim ( p -- p )
- dup length 1 = [ [ zero? ] rtrim ] unless ;
+ dup length 1 = [ [ zero? ] right-trim ] unless ;
: 2ptrim ( p p -- p p ) [ ptrim ] 2apply ;
: p+ ( p p -- p ) pextend v+ ;
"\0" read-until [ drop f ] unless ;
: read-c-string* ( n -- str/f )
- read [ 0 = ] rtrim dup empty? [ drop f ] when ;
+ read [ 0 = ] right-trim dup empty? [ drop f ] when ;
: (read-128-ber) ( n -- n )
1 read first
#! input. This implements the choice parsing operator.
[ or-parser-p1 ] keep or-parser-p2 >r dupd parse swap r> parse lappend ;
-: ltrim-slice ( string -- string )
+: left-trim-slice ( string -- string )
#! Return a new string without any leading whitespace
#! from the original string.
dup empty? [
- dup first blank? [ 1 tail-slice ltrim-slice ] when
+ dup first blank? [ 1 tail-slice left-trim-slice ] when
] unless ;
TUPLE: sp-parser p1 ;
M: sp-parser (parse) ( input parser -- list )
#! Skip all leading whitespace from the input then call
#! the parser on the remaining input.
- >r ltrim-slice r> sp-parser-p1 parse ;
+ >r left-trim-slice r> sp-parser-p1 parse ;
TUPLE: just-parser p1 ;
-USING: kernel math math.vectors sequences self ;
+USING: kernel math math.functions math.vectors sequences self ;
IN: pos
! Long file name
: typeflag-L ( header -- )
<string-writer> [ read-data-blocks ] keep
- >string [ CHAR: \0 = ] rtrim filename set
+ >string [ CHAR: \0 = ] right-trim filename set
global [ "long filename: " write filename get . flush ] bind
filename get tar-path+ make-directories ;
! Copyright (C) 2006, 2007 Alex Chapman
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences math tetris.board tetris.piece
-tetris.tetromino lazy-lists combinators system ;
+USING: kernel sequences math math.functions tetris.board
+tetris.piece tetris.tetromino lazy-lists combinators system ;
IN: tetris.game
TUPLE: tetris pieces last-update update-interval rows score game-state paused? running? ;
--- /dev/null
+USING: tools.deploy sequences io.files io.launcher io
+kernel concurrency prettyprint ;
+
+"." resource-path cd
+
+"deploy-log" make-directory
+
+{
+ "automata.ui"
+ "boids.ui"
+ "bunny"
+ "color-picker"
+ "gesture-logger"
+ "golden-section"
+ "hello-world"
+ "hello-ui"
+ "lsys.ui"
+ "maze"
+ "nehe"
+ "tetris"
+ "catalyst-talk"
+} [
+ dup
+ "deploy-log/" over append <file-writer>
+ [ deploy ] with-stream
+ dup file-length 1024 /f
+ 2array
+] parallel-map .
"." resource-path cd
-"mkdir deploy-log" run-process
+"deploy-log" make-directory
{
"automata.ui"