Merge branch 'master' of git://factorcode.org/git/factor

db4
sheeple 2008-09-02 17:02:32 -05:00
commit 21b74d4abf
70 changed files with 191 additions and 166 deletions

View File

@ -33,8 +33,8 @@ IN: calendar.tests
[ t ] [ 2006 10 10 0 0 0 instant <timestamp> 10 minutes time+ [ t ] [ 2006 10 10 0 0 0 instant <timestamp> 10 minutes time+
2006 10 10 0 10 0 instant <timestamp> = ] unit-test 2006 10 10 0 10 0 instant <timestamp> = ] unit-test
[ t ] [ 2006 10 10 0 0 0 instant <timestamp> 10.5 minutes time+ [ +eq+ ] [ 2006 10 10 0 0 0 instant <timestamp> 10.5 minutes time+
2006 10 10 0 10 30 instant <timestamp> = ] unit-test 2006 10 10 0 10 30 instant <timestamp> <=> ] unit-test
[ t ] [ 2006 10 10 0 0 0 instant <timestamp> 3/4 minutes time+ [ t ] [ 2006 10 10 0 0 0 instant <timestamp> 3/4 minutes time+
2006 10 10 0 0 45 instant <timestamp> = ] unit-test 2006 10 10 0 0 45 instant <timestamp> = ] unit-test
[ t ] [ 2006 10 10 0 0 0 instant <timestamp> -3/4 minutes time+ [ t ] [ 2006 10 10 0 0 0 instant <timestamp> -3/4 minutes time+

View File

@ -278,12 +278,10 @@ GENERIC: time- ( time1 time2 -- time3 )
M: timestamp <=> ( ts1 ts2 -- n ) M: timestamp <=> ( ts1 ts2 -- n )
[ >gmt tuple-slots ] compare ; [ >gmt tuple-slots ] compare ;
<PRIVATE
: (time-) ( timestamp timestamp -- n ) : (time-) ( timestamp timestamp -- n )
[ >gmt ] bi@ [ >gmt ] bi@
[ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep [ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep
[ >time< >r >r 3600 * r> 60 * r> + + ] bi@ - + ; [ >time< >r >r 3600 * r> 60 * r> + + ] bi@ - + ;
PRIVATE>
M: timestamp time- M: timestamp time-
#! Exact calendar-time difference #! Exact calendar-time difference

View File

@ -58,7 +58,7 @@ IN: calendar.format.tests
26 26
0 0
37 37
42.12345 42+2469/20000
T{ duration f 0 0 0 -5 0 0 } T{ duration f 0 0 0 -5 0 0 }
} }
] [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test ] [ "2008-05-26T00:37:42.12345-05:00" rfc3339>timestamp ] unit-test

View File

@ -4,7 +4,7 @@
! Remote Channels ! Remote Channels
USING: kernel init namespaces assocs arrays random USING: kernel init namespaces assocs arrays random
sequences channels match concurrency.messaging sequences channels match concurrency.messaging
concurrency.distributed threads ; concurrency.distributed threads accessors ;
IN: channels.remote IN: channels.remote
<PRIVATE <PRIVATE
@ -52,13 +52,13 @@ TUPLE: remote-channel node id ;
C: <remote-channel> remote-channel C: <remote-channel> remote-channel
M: remote-channel to ( value remote-channel -- ) M: remote-channel to ( value remote-channel -- )
[ [ \ to , remote-channel-id , , ] { } make ] keep [ [ \ to , id>> , , ] { } make ] keep
remote-channel-node "remote-channels" <remote-process> node>> "remote-channels" <remote-process>
send-synchronous no-channel = [ no-channel throw ] when ; send-synchronous no-channel = [ no-channel throw ] when ;
M: remote-channel from ( remote-channel -- value ) M: remote-channel from ( remote-channel -- value )
[ [ \ from , remote-channel-id , ] { } make ] keep [ [ \ from , id>> , ] { } make ] keep
remote-channel-node "remote-channels" <remote-process> node>> "remote-channels" <remote-process>
send-synchronous dup no-channel = [ no-channel throw ] when* ; send-synchronous dup no-channel = [ no-channel throw ] when* ;
[ [

View File

@ -41,7 +41,7 @@ Bar [
-> release -> release
] compile-call ] compile-call
[ 1 ] [ "x" get NSRect-x ] unit-test [ 1.0 ] [ "x" get NSRect-x ] unit-test
[ 2 ] [ "x" get NSRect-y ] unit-test [ 2.0 ] [ "x" get NSRect-y ] unit-test
[ 101 ] [ "x" get NSRect-w ] unit-test [ 101.0 ] [ "x" get NSRect-w ] unit-test
[ 102 ] [ "x" get NSRect-h ] unit-test [ 102.0 ] [ "x" get NSRect-h ] unit-test

View File

@ -27,7 +27,7 @@ ARTICLE: "compiler" "Optimizing compiler"
"The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect; for otherwise, most of the system would be compiled with the non-optimizing compiler. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "." "The optimizing compiler only compiles words which have a static stack effect. This means that methods defined on fundamental generic words such as " { $link nth } " should have a static stack effect; for otherwise, most of the system would be compiled with the non-optimizing compiler. See " { $link "inference" } " and " { $link "cookbook-pitfalls" } "."
{ $subsection "compiler-usage" } { $subsection "compiler-usage" }
{ $subsection "compiler-errors" } { $subsection "compiler-errors" }
{ $subsection "optimizer" } { $subsection "hints" }
{ $subsection "generator" } ; { $subsection "generator" } ;
ABOUT: "compiler" ABOUT: "compiler"

View File

@ -37,7 +37,7 @@ M: remote-process send ( message thread -- )
send-remote-message ; send-remote-message ;
M: thread (serialize) ( obj -- ) M: thread (serialize) ( obj -- )
thread-id local-node get-global <remote-process> id>> local-node get-global <remote-process>
(serialize) ; (serialize) ;
: stop-node ( node -- ) : stop-node ( node -- )

View File

@ -1,10 +1,10 @@
USING: tools.test float-vectors vectors sequences kernel math ;
IN: float-vectors.tests IN: float-vectors.tests
USING: tools.test float-vectors vectors sequences kernel ;
[ 0 ] [ 123 <float-vector> length ] unit-test [ 0 ] [ 123 <float-vector> length ] unit-test
: do-it : do-it
12345 [ over push ] each ; 12345 [ >float over push ] each ;
[ t ] [ [ t ] [
3 <float-vector> do-it 3 <float-vector> do-it

View File

@ -399,5 +399,5 @@ HELP: ABOUT:
{ $description "Defines the main documentation article for the current vocabulary." } ; { $description "Defines the main documentation article for the current vocabulary." } ;
HELP: vocab-help HELP: vocab-help
{ $values { "vocab" "a vocabulary specifier" } { "help" "a help article" } } { $values { "vocab-spec" "a vocabulary specifier" } { "help" "a help article" } }
{ $description "Outputs the main help article for a vocabulary. The main help article can be set with " { $link POSTPONE: ABOUT: } "." } ; { $description "Outputs the main help article for a vocabulary. The main help article can be set with " { $link POSTPONE: ABOUT: } "." } ;

View File

@ -12,7 +12,6 @@ $nl
$nl $nl
"Type hints are declared with a parsing word:" "Type hints are declared with a parsing word:"
{ $subsection POSTPONE: HINTS: } { $subsection POSTPONE: HINTS: }
$nl
"The specialized version of a word which will be compiled by the compiler can be inspected:" "The specialized version of a word which will be compiled by the compiler can be inspected:"
{ $subsection specialized-def } ; { $subsection specialized-def } ;

View File

@ -2,5 +2,10 @@ USING: help.markup help.syntax ;
IN: io.encodings.ascii IN: io.encodings.ascii
HELP: ascii HELP: ascii
{ $class-description "This is the encoding descriptor which denotes an ASCII encoding. By default, if there's a non-ASCII character in an input stream, it will be replaced with a replacement character (U+FFFD), and if a non-ASCII character is used in output, an exception is thrown." } { $class-description "ASCII encoding descriptor." } ;
{ $see-also "encodings-introduction" } ;
ARTICLE: "ascii" "ASCII encoding"
"By default, if there's a non-ASCII character in an input stream, it will be replaced with a replacement character (U+FFFD), and if a non-ASCII character is used in output, an exception is thrown."
{ $subsection ascii } ;
ABOUT: "ascii"

View File

@ -1,7 +1,7 @@
USING: help.markup help.syntax io.encodings strings ; USING: help.markup help.syntax io.encodings strings ;
IN: io.encodings.utf16 IN: io.encodings.utf16
ARTICLE: "io.encodings.utf16" "UTF-16" ARTICLE: "io.encodings.utf16" "UTF-16 encoding"
"The UTF-16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences. There are three encoding descriptor classes for working with UTF-16, depending on endianness or the presence of a BOM:" "The UTF-16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences. There are three encoding descriptor classes for working with UTF-16, depending on endianness or the presence of a BOM:"
{ $subsection utf16 } { $subsection utf16 }
{ $subsection utf16le } { $subsection utf16le }

View File

@ -151,13 +151,13 @@ M: windows kill-process* ( handle -- )
swap win32-error=0/f ; swap win32-error=0/f ;
: process-exited ( process -- ) : process-exited ( process -- )
dup process-handle exit-code dup handle>> exit-code
over process-handle dispose-process over handle>> dispose-process
notify-exit ; notify-exit ;
M: windows wait-for-processes ( -- ? ) M: windows wait-for-processes ( -- ? )
processes get keys dup processes get keys dup
[ process-handle PROCESS_INFORMATION-hProcess ] map [ handle>> PROCESS_INFORMATION-hProcess ] map
dup length swap >c-void*-array 0 0 dup length swap >c-void*-array 0 0
WaitForMultipleObjects WaitForMultipleObjects
dup HEX: ffffffff = [ win32-error ] when dup HEX: ffffffff = [ win32-error ] when

View File

@ -5,9 +5,9 @@ continuations math.parser math arrays sets math.order ;
IN: opengl.capabilities IN: opengl.capabilities
: (require-gl) ( thing require-quot make-error-quot -- ) : (require-gl) ( thing require-quot make-error-quot -- )
>r dupd call -rot dupd call
[ r> 2drop ] [ 2drop ]
[ r> " " make throw ] [ swap " " make throw ]
if ; inline if ; inline
: gl-extensions ( -- seq ) : gl-extensions ( -- seq )

View File

@ -1,4 +1,5 @@
USING: tuple-arrays sequences tools.test namespaces kernel math accessors ; USING: tuple-arrays sequences tools.test namespaces kernel
math accessors ;
IN: tuple-arrays.tests IN: tuple-arrays.tests
SYMBOL: mat SYMBOL: mat
@ -9,7 +10,7 @@ C: <foo> foo
[ T{ foo 2 1 } ] [ T{ foo 2 1 } 0 mat get [ set-nth ] keep first ] unit-test [ T{ foo 2 1 } ] [ T{ foo 2 1 } 0 mat get [ set-nth ] keep first ] unit-test
[ t ] [ { T{ foo f 1 } T{ foo f 2 } } >tuple-array dup mat set tuple-array? ] unit-test [ t ] [ { T{ foo f 1 } T{ foo f 2 } } >tuple-array dup mat set tuple-array? ] unit-test
[ T{ foo f 3 } t ] [ T{ foo f 3 } t ]
[ mat get [ foo-bar 2 + <foo> ] map [ first ] keep tuple-array? ] unit-test [ mat get [ bar>> 2 + <foo> ] map [ first ] keep tuple-array? ] unit-test
[ 2 ] [ 2 foo <tuple-array> dup mat set length ] unit-test [ 2 ] [ 2 foo <tuple-array> dup mat set length ] unit-test
[ T{ foo } ] [ mat get first ] unit-test [ T{ foo } ] [ mat get first ] unit-test

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.lib USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.lib
ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces
classes.tuple colors ; classes.tuple colors accessors ;
IN: ui.gadgets.canvas IN: ui.gadgets.canvas
TUPLE: canvas < gadget dlist ; TUPLE: canvas < gadget dlist ;
@ -11,16 +11,16 @@ TUPLE: canvas < gadget dlist ;
new-gadget black solid-interior ; inline new-gadget black solid-interior ; inline
: delete-canvas-dlist ( canvas -- ) : delete-canvas-dlist ( canvas -- )
dup find-gl-context [ find-gl-context ]
dup canvas-dlist [ delete-dlist ] when* [ dlist>> [ delete-dlist ] when* ]
f swap set-canvas-dlist ; [ f >>dlist drop ] tri ;
: make-canvas-dlist ( canvas quot -- dlist ) : make-canvas-dlist ( canvas quot -- dlist )
over >r GL_COMPILE swap make-dlist dup r> [ GL_COMPILE ] dip make-dlist
set-canvas-dlist ; [ >>dlist drop ] keep ;
: cache-canvas-dlist ( canvas quot -- dlist ) : cache-canvas-dlist ( canvas quot -- dlist )
over canvas-dlist dup over dlist>> dup
[ 2nip ] [ drop make-canvas-dlist ] if ; inline [ 2nip ] [ drop make-canvas-dlist ] if ; inline
: draw-canvas ( canvas quot -- ) : draw-canvas ( canvas quot -- )

View File

@ -1,6 +1,8 @@
USING: ui.backend ui.gadgets.worlds ; USING: accessors kernel ui.backend ui.gadgets.worlds ;
IN: ui.gadgets.lib IN: ui.gadgets.lib
: find-gl-context ( gadget -- ) find-world world-handle select-gl-context ; ERROR: no-world-found ;
: find-gl-context ( gadget -- )
find-world dup [ handle>> select-gl-context ] [ no-world-found ] if ;

View File

@ -46,7 +46,7 @@ HELP: <world>
{ $description "Creates a new " { $link world } " delegating to the given gadget." } ; { $description "Creates a new " { $link world } " delegating to the given gadget." } ;
HELP: find-world HELP: find-world
{ $values { "gadget" gadget } { "world" "a " { $link world } " or " { $link f } } } { $values { "gadget" gadget } { "world/f" "a " { $link world } " or " { $link f } } }
{ $description "Finds the " { $link world } " containing the gadget, or outputs " { $link f } " if the gadget is not grafted." } ; { $description "Finds the " { $link world } " containing the gadget, or outputs " { $link f } " if the gadget is not grafted." } ;
HELP: draw-world HELP: draw-world

View File

@ -149,7 +149,7 @@ M: world selection-notify-event
>r 8 PropModeReplace r> >r 8 PropModeReplace r>
[ [
XSelectionRequestEvent-selection XSelectionRequestEvent-selection
clipboard-for-atom x-clipboard-contents clipboard-for-atom contents>>
] keep encode-clipboard dup length XChangeProperty drop ; ] keep encode-clipboard dup length XChangeProperty drop ;
M: world selection-request-event M: world selection-request-event
@ -188,16 +188,16 @@ M: x11-ui-backend do-events
[ [ 2dup handle-event ] assert-depth ] when 2drop ; [ [ 2dup handle-event ] assert-depth ] when 2drop ;
: x-clipboard@ ( gadget clipboard -- prop win ) : x-clipboard@ ( gadget clipboard -- prop win )
x-clipboard-atom swap atom>> swap
find-world handle>> window>> ; find-world handle>> window>> ;
M: x-clipboard copy-clipboard M: x-clipboard copy-clipboard
[ x-clipboard@ own-selection ] keep [ x-clipboard@ own-selection ] keep
set-x-clipboard-contents ; (>>contents) ;
M: x-clipboard paste-clipboard M: x-clipboard paste-clipboard
>r find-world handle>> window>> >r find-world handle>> window>>
r> x-clipboard-atom convert-selection ; r> atom>> convert-selection ;
: init-clipboard ( -- ) : init-clipboard ( -- )
XA_PRIMARY <x-clipboard> selection set-global XA_PRIMARY <x-clipboard> selection set-global

View File

@ -48,7 +48,7 @@ TUPLE: base64 string ;
C: <base64> base64 C: <base64> base64
M: base64 item>xml M: base64 item>xml
base64-string >base64 "base64" build-tag ; string>> >base64 "base64" build-tag ;
: params ( seq -- xml ) : params ( seq -- xml )
[ item>xml "value" build-tag "param" build-tag ] map [ item>xml "value" build-tag "param" build-tag ] map
@ -80,11 +80,11 @@ C: <rpc-fault> rpc-fault
GENERIC: send-rpc ( rpc -- xml ) GENERIC: send-rpc ( rpc -- xml )
M: rpc-method send-rpc M: rpc-method send-rpc
[ rpc-method-name ] keep rpc-method-params method-call ; [ name>> ] [ params>> ] bi method-call ;
M: rpc-response send-rpc M: rpc-response send-rpc
rpc-response-params return-params ; params>> return-params ;
M: rpc-fault send-rpc M: rpc-fault send-rpc
[ rpc-fault-code ] keep rpc-fault-string return-fault ; [ code>> ] [ string>> ] bi return-fault ;
! * Recieving RPC requests ! * Recieving RPC requests
! this needs to have much better error checking ! this needs to have much better error checking
@ -96,8 +96,8 @@ TUPLE: server-error tag message ;
M: server-error error. M: server-error error.
"Error in XML supplied to server" print "Error in XML supplied to server" print
"Description: " write dup server-error-message print "Description: " write dup message>> print
"Tag: " write server-error-tag xml>string print ; "Tag: " write tag>> xml>string print ;
PROCESS: xml>item ( tag -- object ) PROCESS: xml>item ( tag -- object )
@ -139,8 +139,8 @@ TAG: array xml>item
first-child-tag params>array ; first-child-tag params>array ;
: parse-method ( xml -- string array ) : parse-method ( xml -- string array )
children-tags dup first children>string children-tags first2
swap second params>array ; [ children>string ] [ params>array ] bi* ;
: parse-fault ( xml -- fault-code fault-string ) : parse-fault ( xml -- fault-code fault-string )
first-child-tag first-child-tag first-child-tag first-child-tag first-child-tag first-child-tag

View File

@ -2,5 +2,10 @@ USING: help.syntax help.markup ;
IN: io.encodings.binary IN: io.encodings.binary
HELP: binary HELP: binary
{ $class-description "This is the encoding descriptor for binary I/O. Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings." } { $class-description "Encoding descriptor for binary I/O." } ;
{ $see-also "encodings-introduction" } ;
ARTICLE: "io.encodings.binary" "Binary encoding"
"Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings."
{ $subsection binary } ;
ABOUT: "io.encodings.binary"

View File

@ -2,5 +2,10 @@ USING: help.markup help.syntax ;
IN: io.encodings.utf8 IN: io.encodings.utf8
HELP: utf8 HELP: utf8
{ $class-description "This is the encoding descriptor for a UTF-8 encoding. UTF-8 is a variable-width encoding. 7-bit ASCII characters are encoded as single bytes, and other Unicode code points are encoded as 2 to 4 byte sequences." } { $class-description "Encoding descriptor for UTF-8 encoding." } ;
{ $see-also "encodings-introduction" } ;
ARTICLE: "io.encodings.utf8" "UTF-8 encoding"
"UTF-8 is a variable-width encoding. 7-bit ASCII characters are encoded as single bytes, and other Unicode code points are encoded as 2 to 4 byte sequences."
{ $subsection utf8 } ;
ABOUT: "io.encodings.utf8"

View File

@ -66,7 +66,7 @@ HELP: number=
{ $notes "This word differs from " { $link = } " in that it disregards differences in type when comparing numbers." } { $notes "This word differs from " { $link = } " in that it disregards differences in type when comparing numbers." }
{ $examples { $examples
{ $example "USING: math prettyprint ;" "3.0 3 number= ." "t" } { $example "USING: math prettyprint ;" "3.0 3 number= ." "t" }
{ $example "USING: math prettyprint ;" "3.0 3 = ." "f" } { $example "USING: kernel math prettyprint ;" "3.0 3 = ." "f" }
} ; } ;
HELP: < HELP: <
@ -294,7 +294,7 @@ HELP: times
{ $description "Calls the quotation " { $snippet "n" } " times." } { $description "Calls the quotation " { $snippet "n" } " times." }
{ $notes "If you need to pass the current index to the quotation, use " { $link each } "." } { $notes "If you need to pass the current index to the quotation, use " { $link each } "." }
{ $examples { $examples
{ $example "USING: io math ;" "3 [ \"Hi\" print ] times" "Hi\nHi\nHi\n" } { $example "USING: io math ;" "3 [ \"Hi\" print ] times" "Hi\nHi\nHi" }
} ; } ;
HELP: fp-nan? HELP: fp-nan?
@ -304,14 +304,14 @@ HELP: fp-nan?
HELP: real-part HELP: real-part
{ $values { "z" number } { "x" real } } { $values { "z" number } { "x" real } }
{ $description "Outputs the real part of a complex number. This acts as the identity on real numbers." } { $description "Outputs the real part of a complex number. This acts as the identity on real numbers." }
{ $examples { $example "C{ 1 2 } real-part ." "1" } } ; { $examples { $example "USING: math prettyprint ; C{ 1 2 } real-part ." "1" } } ;
HELP: imaginary-part HELP: imaginary-part
{ $values { "z" number } { "y" real } } { $values { "z" number } { "y" real } }
{ $description "Outputs the imaginary part of a complex number. This outputs zero for real numbers." } { $description "Outputs the imaginary part of a complex number. This outputs zero for real numbers." }
{ $examples { $examples
{ $example "C{ 1 2 } imaginary-part ." "2" } { $example "USING: math prettyprint ; C{ 1 2 } imaginary-part ." "2" }
{ $example "3 imaginary-part ." "0" } { $example "USING: math prettyprint ; 3 imaginary-part ." "0" }
} ; } ;
HELP: real HELP: real

View File

@ -17,7 +17,7 @@ $nl
"Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:" "Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:"
{ $subsection wrapper } { $subsection wrapper }
{ $subsection literalize } { $subsection literalize }
{ $see-also "basic-combinators" "combinators" } ; { $see-also "dataflow" "combinators" } ;
ABOUT: "quotations" ABOUT: "quotations"

View File

@ -390,7 +390,7 @@ HELP: P"
{ $syntax "P\" pathname\"" } { $syntax "P\" pathname\"" }
{ $values { "pathname" "a pathname string" } } { $values { "pathname" "a pathname string" } }
{ $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", creates a new " { $link pathname } ", and appends it to the parse tree." } { $description "Reads from the input string until the next occurrence of " { $link POSTPONE: " } ", creates a new " { $link pathname } ", and appends it to the parse tree." }
{ $examples { $example "USING: io io.files ;" "P\" foo.txt\" pathname-string print" "foo.txt" } } ; { $examples { $example "USING: accessors io io.files ;" "P\" foo.txt\" string>> print" "foo.txt" } } ;
HELP: ( HELP: (
{ $syntax "( inputs -- outputs )" } { $syntax "( inputs -- outputs )" }

View File

@ -50,7 +50,7 @@ HELP: load-vocab
{ $error-description "Thrown by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " when a given vocabulary does not exist. Vocabularies must be created by " { $link POSTPONE: IN: } " before being used." } ; { $error-description "Thrown by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " when a given vocabulary does not exist. Vocabularies must be created by " { $link POSTPONE: IN: } " before being used." } ;
HELP: vocab-main HELP: vocab-main
{ $values { "vocab" "a vocabulary specifier" } { "main" word } } { $values { "vocab-spec" "a vocabulary specifier" } { "main" word } }
{ $description "Outputs the main entry point for a vocabulary. The entry point can be executed with " { $link run } " and set with " { $link POSTPONE: MAIN: } "." } ; { $description "Outputs the main entry point for a vocabulary. The entry point can be executed with " { $link run } " and set with " { $link POSTPONE: MAIN: } "." } ;
HELP: vocab-roots HELP: vocab-roots

View File

@ -46,19 +46,19 @@ HELP: vocab
{ $class-description "Instances represent vocabularies." } ; { $class-description "Instances represent vocabularies." } ;
HELP: vocab-name HELP: vocab-name
{ $values { "vocab" "a vocabulary specifier" } { "name" string } } { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
{ $description "Outputs the name of a vocabulary." } ; { $description "Outputs the name of a vocabulary." } ;
HELP: vocab-words HELP: vocab-words
{ $values { "vocab" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } } { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
{ $description "Outputs the words defined in a vocabulary." } ; { $description "Outputs the words defined in a vocabulary." } ;
HELP: vocab-source-loaded? HELP: vocab-source-loaded?
{ $values { "vocab" "a vocabulary specifier" } { "source-loaded?" "a boolean" } } { $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
{ $description "Outputs if the source for this vocubulary has been loaded." } ; { $description "Outputs if the source for this vocubulary has been loaded." } ;
HELP: vocab-docs-loaded? HELP: vocab-docs-loaded?
{ $values { "vocab" "a vocabulary specifier" } { "docs-loaded?" "a boolean" } } { $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
{ $description "Outputs if the documentation for this vocubulary has been loaded." } ; { $description "Outputs if the documentation for this vocubulary has been loaded." } ;
HELP: words HELP: words

View File

@ -184,7 +184,7 @@ TUPLE: tag value ;
tagnum get (>>value) ; tagnum get (>>value) ;
M: string >ber ( str -- byte-array ) M: string >ber ( str -- byte-array )
tagnum get tag-value 1array "C" pack-native swap dup tagnum get value>> 1array "C" pack-native swap dup
length >ber-length-encoding swapd append swap length >ber-length-encoding swapd append swap
>byte-array append ; >byte-array append ;

View File

@ -121,25 +121,25 @@ VARS: population-label cohesion-label alignment-label separation-label ;
"1 - Randomize" [ drop randomize ] button* add-gadget "1 - Randomize" [ drop randomize ] button* add-gadget
<pile> 1 over set-pack-fill <pile> 1 >>fill
population-label> add-gadget population-label> add-gadget
"3 - Add 10" [ drop add-10-boids ] button* add-gadget "3 - Add 10" [ drop add-10-boids ] button* add-gadget
"2 - Sub 10" [ drop sub-10-boids ] button* add-gadget "2 - Sub 10" [ drop sub-10-boids ] button* add-gadget
add-gadget add-gadget
<pile> 1 over set-pack-fill <pile> 1 >>fill
cohesion-label> add-gadget cohesion-label> add-gadget
"q - +0.1" [ drop inc-cohesion-weight ] button* add-gadget "q - +0.1" [ drop inc-cohesion-weight ] button* add-gadget
"a - -0.1" [ drop dec-cohesion-weight ] button* add-gadget "a - -0.1" [ drop dec-cohesion-weight ] button* add-gadget
add-gadget add-gadget
<pile> 1 over set-pack-fill <pile> 1 >>fill
alignment-label> add-gadget alignment-label> add-gadget
"w - +0.1" [ drop inc-alignment-weight ] button* add-gadget "w - +0.1" [ drop inc-alignment-weight ] button* add-gadget
"s - -0.1" [ drop dec-alignment-weight ] button* add-gadget "s - -0.1" [ drop dec-alignment-weight ] button* add-gadget
add-gadget add-gadget
<pile> 1 over set-pack-fill <pile> 1 >>fill
separation-label> add-gadget separation-label> add-gadget
"e - +0.1" [ drop inc-separation-weight ] button* add-gadget "e - +0.1" [ drop inc-separation-weight ] button* add-gadget
"d - -0.1" [ drop dec-separation-weight ] button* add-gadget "d - -0.1" [ drop dec-separation-weight ] button* add-gadget

View File

@ -139,11 +139,7 @@ TUPLE: bunny-outlined
: <bunny-outlined> ( gadget -- draw ) : <bunny-outlined> ( gadget -- draw )
outlining-supported? [ outlining-supported? [
pass1-program pass2-program { pass1-program pass2-program f f f f f bunny-outlined boa
(>>gadget)
(>>pass1-program)
(>>pass2-program)
} bunny-outlined construct
] [ drop f ] if ; ] [ drop f ] if ;
: (framebuffer-texture) ( dim iformat xformat -- texture ) : (framebuffer-texture) ( dim iformat xformat -- texture )

View File

@ -10,7 +10,7 @@ IN: color-picker
! Simple example demonstrating the use of models. ! Simple example demonstrating the use of models.
: <color-slider> ( model -- gadget ) : <color-slider> ( model -- gadget )
<x-slider> 1 over set-slider-line ; <x-slider> 1 >>line ;
TUPLE: color-preview < gadget ; TUPLE: color-preview < gadget ;
@ -20,7 +20,7 @@ TUPLE: color-preview < gadget ;
{ 100 100 } >>dim ; { 100 100 } >>dim ;
M: color-preview model-changed M: color-preview model-changed
swap model-value over set-gadget-interior relayout-1 ; swap value>> >>interior relayout-1 ;
: <color-model> ( model -- model ) : <color-model> ( model -- model )
[ [ 256 /f ] map 1 suffix first4 rgba boa <solid> ] <filter> ; [ [ 256 /f ] map 1 suffix first4 rgba boa <solid> ] <filter> ;

View File

@ -41,9 +41,9 @@ SYMBOL: person4
[ ] [ person1 get insert-tuple ] unit-test [ ] [ person1 get insert-tuple ] unit-test
[ 1 ] [ person1 get person-the-id ] unit-test [ 1 ] [ person1 get the-id>> ] unit-test
[ ] [ 200 person1 get set-person-the-number ] unit-test [ ] [ person1 get 200 >>the-number drop ] unit-test
[ ] [ person1 get update-tuple ] unit-test [ ] [ person1 get update-tuple ] unit-test

View File

@ -336,7 +336,7 @@ M: wrapper (parse-factor-quotation) ( object -- ast )
GENERIC: fjsc-parse ( object -- ast ) GENERIC: fjsc-parse ( object -- ast )
M: string fjsc-parse ( object -- ast ) M: string fjsc-parse ( object -- ast )
'expression' parse parse-result-ast ; 'expression' parse ast>> ;
M: quotation fjsc-parse ( object -- ast ) M: quotation fjsc-parse ( object -- ast )
[ [

View File

@ -203,6 +203,6 @@ CHLOE: button
{ {
[ [ attrs>> chloe-attrs-only ] dip add-tag-attrs ] [ [ attrs>> chloe-attrs-only ] dip add-tag-attrs ]
[ [ attrs>> non-chloe-attrs-only ] dip "button" tag-named add-tag-attrs ] [ [ attrs>> non-chloe-attrs-only ] dip "button" tag-named add-tag-attrs ]
[ [ children>string 1array ] dip "button" tag-named set-tag-children ] [ [ children>string 1array ] dip "button" tag-named (>>children) ]
[ nip ] [ nip ]
} 2cleave process-chloe-tag ; } 2cleave process-chloe-tag ;

View File

@ -2,12 +2,14 @@ USING: eval multiline system combinators ;
IN: game-input.backend IN: game-input.backend
STRING: set-backend-for-macosx STRING: set-backend-for-macosx
USING: namespaces game-input.backend.iokit game-input ; USING: namespaces parser game-input.backend.iokit ;
<< "game-input" (use+) >>
iokit-game-input-backend game-input-backend set-global iokit-game-input-backend game-input-backend set-global
; ;
STRING: set-backend-for-windows STRING: set-backend-for-windows
USING: namespaces game-input.backend.dinput game-input ; USING: namespaces parser game-input.backend.dinput ;
<< "game-input" (use+) >>
dinput-game-input-backend game-input-backend set-global dinput-game-input-backend game-input-backend set-global
; ;

View File

@ -1,10 +1,11 @@
USING: windows.dinput windows.dinput.constants game-input USING: windows.dinput windows.dinput.constants parser
symbols alien.c-types windows.ole32 namespaces assocs kernel symbols alien.c-types windows.ole32 namespaces assocs kernel
arrays vectors windows.kernel32 windows.com windows.dinput arrays vectors windows.kernel32 windows.com windows.dinput
shuffle windows.user32 windows.messages sequences combinators shuffle windows.user32 windows.messages sequences combinators
math.geometry.rect ui.windows accessors math windows alien math.geometry.rect ui.windows accessors math windows alien
alien.strings io.encodings.utf16 continuations byte-arrays alien.strings io.encodings.utf16 continuations byte-arrays
locals game-input.backend.dinput.keys-array ; locals game-input.backend.dinput.keys-array ;
<< "game-input" (use+) >>
IN: game-input.backend.dinput IN: game-input.backend.dinput
SINGLETON: dinput-game-input-backend SINGLETON: dinput-game-input-backend

View File

@ -1,9 +1,10 @@
USING: cocoa cocoa.plists core-foundation iokit iokit.hid USING: cocoa cocoa.plists core-foundation iokit iokit.hid
kernel cocoa.enumeration destructors math.parser cocoa.application kernel cocoa.enumeration destructors math.parser cocoa.application
sequences locals combinators.short-circuit game-input threads sequences locals combinators.short-circuit threads
symbols namespaces assocs vectors arrays combinators symbols namespaces assocs vectors arrays combinators
core-foundation.run-loop accessors sequences.private core-foundation.run-loop accessors sequences.private
alien.c-types math ; alien.c-types math parser ;
<< "game-input" (use+) >>
IN: game-input.backend.iokit IN: game-input.backend.iokit
SINGLETON: iokit-game-input-backend SINGLETON: iokit-game-input-backend

View File

@ -28,7 +28,6 @@ M: f (reset-game-input) ;
PRIVATE> PRIVATE>
: open-game-input ( -- ) : open-game-input ( -- )
load-game-input-backend
game-input-opened? [ game-input-opened? [
(open-game-input) (open-game-input)
game-input-opened on game-input-opened on
@ -76,3 +75,6 @@ M: keyboard-state clone
call-next-method dup keys>> clone >>keys ; call-next-method dup keys>> clone >>keys ;
HOOK: read-keyboard game-input-backend ( -- keyboard-state ) HOOK: read-keyboard game-input-backend ( -- keyboard-state )
load-game-input-backend

View File

@ -19,7 +19,7 @@ M: gesture-logger handle-gesture
t ; t ;
M: gesture-logger user-input* M: gesture-logger user-input*
gesture-logger-stream [ stream>> [
"User input: " write print "User input: " write print
] with-output-stream* t ; ] with-output-stream* t ;

View File

@ -1,8 +1,6 @@
USING: html.streams html.streams.private accessors io
USING: html.streams html.streams.private io.streams.string io.styles kernel namespaces tools.test
io io.streams.string io.styles kernel xml.writer sbufs sequences inspector colors ;
namespaces tools.test xml.writer sbufs sequences inspector colors ;
IN: html.streams.tests IN: html.streams.tests
: make-html-string : make-html-string
@ -33,7 +31,7 @@ IN: html.streams.tests
TUPLE: funky town ; TUPLE: funky town ;
M: funky browser-link-href M: funky browser-link-href
"http://www.funky-town.com/" swap funky-town append ; "http://www.funky-town.com/" swap town>> append ;
[ "<a href='http://www.funky-town.com/austin'>&lt;</a>" ] [ [ "<a href='http://www.funky-town.com/austin'>&lt;</a>" ] [
[ [

View File

@ -32,7 +32,7 @@ C: <foo> foo
: f>c ( *fahrenheit -- *celsius ) : f>c ( *fahrenheit -- *celsius )
32 - 1.8 / ; 32 - 1.8 / ;
[ { 212 32 } ] [ { 100 0 } [ [ f>c ] map ] undo ] unit-test [ { 212.0 32.0 } ] [ { 100 0 } [ [ f>c ] map ] undo ] unit-test
[ { t t f } ] [ { t f 1 } [ [ >boolean ] matches? ] map ] unit-test [ { t t f } ] [ { t f 1 } [ [ >boolean ] matches? ] map ] unit-test
[ { t f } ] [ { { 1 2 3 } 4 } [ [ >array ] matches? ] map ] unit-test [ { t f } ] [ { { 1 2 3 } 4 } [ [ >array ] matches? ] map ] unit-test
[ 9 9 ] [ 3 [ 1/2 ^ ] undo 3 [ sqrt ] undo ] unit-test [ 9 9 ] [ 3 [ 1/2 ^ ] undo 3 [ sqrt ] undo ] unit-test

View File

@ -208,7 +208,7 @@ DEFER: _
: slot-readers ( class -- quot ) : slot-readers ( class -- quot )
all-slots rest ! tail gets rid of delegate all-slots rest ! tail gets rid of delegate
[ reader>> 1quotation [ keep ] curry ] map concat [ name>> reader-word 1quotation [ keep ] curry ] map concat
[ ] like [ drop ] compose ; [ ] like [ drop ] compose ;
: ?wrapped ( object -- wrapped ) : ?wrapped ( object -- wrapped )

View File

@ -0,0 +1,15 @@
USING: tools.deploy.config ;
H{
{ deploy-name "joystick-demo" }
{ deploy-io 2 }
{ deploy-word-defs? f }
{ deploy-c-types? t }
{ deploy-random? t }
{ deploy-word-props? f }
{ deploy-reflection 1 }
{ deploy-threads? t }
{ deploy-math? t }
{ "stop-after-last-window?" t }
{ deploy-ui? t }
{ deploy-compiler? t }
}

View File

@ -11,9 +11,9 @@ IN: json.reader.tests
{ 102.0 } [ "102.0" json> ] unit-test { 102.0 } [ "102.0" json> ] unit-test
{ 102.5 } [ "102.5" json> ] unit-test { 102.5 } [ "102.5" json> ] unit-test
{ 102.5 } [ "102.50" json> ] unit-test { 102.5 } [ "102.50" json> ] unit-test
{ -10250 } [ "-102.5e2" json> ] unit-test { -10250.0 } [ "-102.5e2" json> ] unit-test
{ -10250 } [ "-102.5E+2" json> ] unit-test { -10250.0 } [ "-102.5E+2" json> ] unit-test
{ 10.25 } [ "1025e-2" json> ] unit-test { 10+1/4 } [ "1025e-2" json> ] unit-test
{ 0.125 } [ "0.125" json> ] unit-test { 0.125 } [ "0.125" json> ] unit-test
{ -0.125 } [ "-0.125" json> ] unit-test { -0.125 } [ "-0.125" json> ] unit-test

View File

@ -26,7 +26,7 @@ IN: lcd
: <time-display> ( timestamp -- gadget ) : <time-display> ( timestamp -- gadget )
[ hh:mm:ss lcd ] <filter> <label-control> [ hh:mm:ss lcd ] <filter> <label-control>
"99:99:99" lcd over set-label-string "99:99:99" lcd over set-label-string
monospace-font over set-label-font ; monospace-font >>font ;
: time-window ( -- ) : time-window ( -- )
[ time get <time-display> "Time" open-window ] with-ui ; [ time get <time-display> "Time" open-window ] with-ui ;

View File

@ -71,8 +71,8 @@ HELP: derivative-func
{ $examples { $examples
{ $example { $example
"USING: kernel math.derivatives math.functions math.trig prettyprint ;" "USING: kernel math.derivatives math.functions math.trig prettyprint ;"
"60 deg>rad [ sin ] derivative-func call ." "60 deg>rad [ sin ] derivative-func call 0.5 .001 ~ ."
"0.5000000000000173" "t"
} }
{ $notes { $notes
"Without a heavy algebraic system, derivatives must be " "Without a heavy algebraic system, derivatives must be "

View File

@ -22,7 +22,7 @@ USING: kernel math math.polynomials tools.test ;
[ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 } { 1 1 } p/mod ] unit-test [ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 } { 1 1 } p/mod ] unit-test
[ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 } { 1 1 0 0 0 0 0 0 } p/mod ] unit-test [ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 } { 1 1 0 0 0 0 0 0 } p/mod ] unit-test
[ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 0 0 0 0 } { 1 1 0 0 } p/mod ] unit-test [ V{ 1 0 1 } V{ 0 0 0 } ] [ { 1 1 1 1 0 0 0 0 } { 1 1 0 0 } p/mod ] unit-test
[ V{ 5.0 } V{ 0.0 } ] [ { 10.0 } { 2.0 } p/mod ] unit-test [ V{ 5.0 } V{ 0 } ] [ { 10.0 } { 2.0 } p/mod ] unit-test
[ V{ 15/16 } V{ 0 } ] [ { 3/4 } { 4/5 } p/mod ] unit-test [ V{ 15/16 } V{ 0 } ] [ { 3/4 } { 4/5 } p/mod ] unit-test
[ t ] [ { 0 1 } { 0 1 0 } p= ] unit-test [ t ] [ { 0 1 } { 0 1 0 } p= ] unit-test
[ f ] [ { 0 0 1 } { 0 1 0 } p= ] unit-test [ f ] [ { 0 0 1 } { 0 1 0 } p= ] unit-test

View File

@ -2,11 +2,11 @@ IN: math.quaternions.tests
USING: tools.test math.quaternions kernel math.vectors USING: tools.test math.quaternions kernel math.vectors
math.constants ; math.constants ;
[ 1 ] [ qi norm ] unit-test [ 1.0 ] [ qi norm ] unit-test
[ 1 ] [ qj norm ] unit-test [ 1.0 ] [ qj norm ] unit-test
[ 1 ] [ qk norm ] unit-test [ 1.0 ] [ qk norm ] unit-test
[ 1 ] [ q1 norm ] unit-test [ 1.0 ] [ q1 norm ] unit-test
[ 0 ] [ q0 norm ] unit-test [ 0.0 ] [ q0 norm ] unit-test
[ t ] [ qi qj q* qk = ] unit-test [ t ] [ qi qj q* qk = ] unit-test
[ t ] [ qj qk q* qi = ] unit-test [ t ] [ qj qk q* qi = ] unit-test
[ t ] [ qk qi q* qj = ] unit-test [ t ] [ qk qi q* qj = ] unit-test

View File

@ -5,7 +5,7 @@ IN: math.statistics.tests
[ 3/2 ] [ { 1 2 } mean ] unit-test [ 3/2 ] [ { 1 2 } mean ] unit-test
[ 0 ] [ { 0 0 0 } geometric-mean ] unit-test [ 0 ] [ { 0 0 0 } geometric-mean ] unit-test
[ t ] [ { 2 2 2 2 } geometric-mean 2.0 .0001 ~ ] unit-test [ t ] [ { 2 2 2 2 } geometric-mean 2.0 .0001 ~ ] unit-test
[ 1 ] [ { 1 1 1 } geometric-mean ] unit-test [ 1.0 ] [ { 1 1 1 } geometric-mean ] unit-test
[ 1/3 ] [ { 1 1 1 } harmonic-mean ] unit-test [ 1/3 ] [ { 1 1 1 } harmonic-mean ] unit-test
[ 0 ] [ { 1 } range ] unit-test [ 0 ] [ { 1 } range ] unit-test
@ -14,12 +14,11 @@ IN: math.statistics.tests
[ 5/2 ] [ { 1 2 3 4 } median ] unit-test [ 5/2 ] [ { 1 2 3 4 } median ] unit-test
[ 1 ] [ { 1 2 3 } var ] unit-test [ 1 ] [ { 1 2 3 } var ] unit-test
[ 1 ] [ { 1 2 3 } std ] unit-test [ 1.0 ] [ { 1 2 3 } std ] unit-test
[ t ] [ { 1 2 3 4 } ste 0.6454972243679028 - .0001 < ] unit-test [ t ] [ { 1 2 3 4 } ste 0.6454972243679028 - .0001 < ] unit-test
[ t ] [ { 23.2 33.4 22.5 66.3 44.5 } std 18.1906 - .0001 < ] unit-test [ t ] [ { 23.2 33.4 22.5 66.3 44.5 } std 18.1906 - .0001 < ] unit-test
[ 0 ] [ { 1 } var ] unit-test [ 0 ] [ { 1 } var ] unit-test
[ 0 ] [ { 1 } std ] unit-test [ 0.0 ] [ { 1 } std ] unit-test
[ 0 ] [ { 1 } ste ] unit-test [ 0.0 ] [ { 1 } ste ] unit-test

View File

@ -31,7 +31,7 @@ M: nehe4-gadget draw-gadget* ( gadget -- )
GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
glLoadIdentity glLoadIdentity
-1.5 0.0 -6.0 glTranslatef -1.5 0.0 -6.0 glTranslatef
dup nehe4-gadget-rtri 0.0 1.0 0.0 glRotatef dup rtri>> 0.0 1.0 0.0 glRotatef
GL_TRIANGLES [ GL_TRIANGLES [
1.0 0.0 0.0 glColor3f 1.0 0.0 0.0 glColor3f
@ -45,7 +45,7 @@ M: nehe4-gadget draw-gadget* ( gadget -- )
glLoadIdentity glLoadIdentity
1.5 0.0 -6.0 glTranslatef 1.5 0.0 -6.0 glTranslatef
dup nehe4-gadget-rquad 1.0 0.0 0.0 glRotatef dup rquad>> 1.0 0.0 0.0 glRotatef
0.5 0.5 1.0 glColor3f 0.5 0.5 1.0 glColor3f
GL_QUADS [ GL_QUADS [
-1.0 1.0 0.0 glVertex3f -1.0 1.0 0.0 glVertex3f

View File

@ -30,7 +30,7 @@ M: nehe5-gadget draw-gadget* ( gadget -- )
GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
glLoadIdentity glLoadIdentity
-1.5 0.0 -6.0 glTranslatef -1.5 0.0 -6.0 glTranslatef
dup nehe5-gadget-rtri 0.0 1.0 0.0 glRotatef dup rtri>> 0.0 1.0 0.0 glRotatef
GL_TRIANGLES [ GL_TRIANGLES [
1.0 0.0 0.0 glColor3f 1.0 0.0 0.0 glColor3f
@ -65,7 +65,7 @@ M: nehe5-gadget draw-gadget* ( gadget -- )
glLoadIdentity glLoadIdentity
1.5 0.0 -7.0 glTranslatef 1.5 0.0 -7.0 glTranslatef
dup nehe5-gadget-rquad 1.0 0.0 0.0 glRotatef dup rquad>> 1.0 0.0 0.0 glRotatef
GL_QUADS [ GL_QUADS [
0.0 1.0 0.0 glColor3f 0.0 1.0 0.0 glColor3f
1.0 1.0 -1.0 glVertex3f 1.0 1.0 -1.0 glVertex3f

View File

@ -59,7 +59,7 @@ C: <token-parser> token-parser
: case-insensitive-token ( string -- parser ) t <token-parser> ; : case-insensitive-token ( string -- parser ) t <token-parser> ;
M: token-parser parse ( input parser -- list ) M: token-parser parse ( input parser -- list )
dup token-parser-string swap token-parser-ignore-case? [ string>> ] [ ignore-case?>> ] bi
>r tuck r> ?string-head >r tuck r> ?string-head
[ <parse-results> ] [ 2drop nil ] if ; [ <parse-results> ] [ 2drop nil ] if ;
@ -76,7 +76,7 @@ M: satisfy-parser parse ( input parser -- list )
over empty? [ over empty? [
2drop nil 2drop nil
] [ ] [
satisfy-parser-quot >r unclip-slice dup r> call quot>> >r unclip-slice dup r> call
[ swap <parse-results> ] [ 2drop nil ] if [ swap <parse-results> ] [ 2drop nil ] if
] if ; ] if ;
@ -101,7 +101,7 @@ C: succeed succeed-parser ( result -- parser )
M: succeed-parser parse ( input parser -- list ) M: succeed-parser parse ( input parser -- list )
#! A parser that always returns 'result' as a #! A parser that always returns 'result' as a
#! successful parse with no input consumed. #! successful parse with no input consumed.
succeed-parser-result swap <parse-results> ; result>> swap <parse-results> ;
TUPLE: fail-parser ; TUPLE: fail-parser ;
@ -118,7 +118,7 @@ TUPLE: ensure-parser test ;
ensure-parser boa ; ensure-parser boa ;
M: ensure-parser parse ( input parser -- list ) M: ensure-parser parse ( input parser -- list )
2dup ensure-parser-test parse nil? 2dup test>> parse nil?
[ 2drop nil ] [ drop t swap <parse-results> ] if ; [ 2drop nil ] [ drop t swap <parse-results> ] if ;
TUPLE: ensure-not-parser test ; TUPLE: ensure-not-parser test ;
@ -127,7 +127,7 @@ TUPLE: ensure-not-parser test ;
ensure-not-parser boa ; ensure-not-parser boa ;
M: ensure-not-parser parse ( input parser -- list ) M: ensure-not-parser parse ( input parser -- list )
2dup ensure-not-parser-test parse nil? 2dup test>> parse nil?
[ drop t swap <parse-results> ] [ 2drop nil ] if ; [ drop t swap <parse-results> ] [ 2drop nil ] if ;
TUPLE: and-parser parsers ; TUPLE: and-parser parsers ;
@ -157,7 +157,7 @@ M: and-parser parse ( input parser -- list )
#! two parsers. First parser1 is applied to the #! two parsers. First parser1 is applied to the
#! input then parser2 is applied to the rest of #! input then parser2 is applied to the rest of
#! the input strings from the first parser. #! the input strings from the first parser.
and-parser-parsers unclip swapd parse parsers>> unclip swapd parse
[ [ and-parser-parse ] reduce ] 2curry promise ; [ [ and-parser-parse ] reduce ] 2curry promise ;
TUPLE: or-parser parsers ; TUPLE: or-parser parsers ;
@ -172,7 +172,7 @@ M: or-parser parse ( input parser1 -- list )
#! Return the combined list resulting from the parses #! Return the combined list resulting from the parses
#! of parser1 and parser2 being applied to the same #! of parser1 and parser2 being applied to the same
#! input. This implements the choice parsing operator. #! input. This implements the choice parsing operator.
or-parser-parsers 0 swap seq>list parsers>> 0 swap seq>list
[ parse ] lazy-map-with lconcat ; [ parse ] lazy-map-with lconcat ;
: left-trim-slice ( string -- string ) : left-trim-slice ( string -- string )
@ -191,7 +191,7 @@ C: sp sp-parser ( p1 -- parser )
M: sp-parser parse ( input parser -- list ) M: sp-parser parse ( input parser -- list )
#! Skip all leading whitespace from the input then call #! Skip all leading whitespace from the input then call
#! the parser on the remaining input. #! the parser on the remaining input.
>r left-trim-slice r> sp-parser-p1 parse ; >r left-trim-slice r> p1>> parse ;
TUPLE: just-parser p1 ; TUPLE: just-parser p1 ;
@ -202,7 +202,7 @@ M: just-parser parse ( input parser -- result )
#! from the results anything where the remaining #! from the results anything where the remaining
#! input to be parsed is not empty. So ensures a #! input to be parsed is not empty. So ensures a
#! fully parsed input string. #! fully parsed input string.
just-parser-p1 parse [ parse-result-unparsed empty? ] lfilter ; p1>> parse [ unparsed>> empty? ] lfilter ;
TUPLE: apply-parser p1 quot ; TUPLE: apply-parser p1 quot ;
@ -214,10 +214,10 @@ M: apply-parser parse ( input parser -- result )
#! The result of that quotation then becomes the new parse result. #! The result of that quotation then becomes the new parse result.
#! This allows modification of parse tree results (like #! This allows modification of parse tree results (like
#! converting strings to integers, etc). #! converting strings to integers, etc).
[ apply-parser-p1 ] keep apply-parser-quot [ p1>> ] [ quot>> ] bi
-rot parse [ -rot parse [
[ parse-result-parsed swap call ] keep [ parsed>> swap call ] keep
parse-result-unparsed <parse-result> unparsed>> <parse-result>
] lazy-map-with ; ] lazy-map-with ;
TUPLE: some-parser p1 ; TUPLE: some-parser p1 ;
@ -229,7 +229,7 @@ M: some-parser parse ( input parser -- result )
#! the parse is complete (the remaining input is empty), #! the parse is complete (the remaining input is empty),
#! picks the first solution and only returns the parse #! picks the first solution and only returns the parse
#! tree since the remaining input is empty. #! tree since the remaining input is empty.
some-parser-p1 just parse-1 ; p1>> just parse-1 ;
: <& ( parser1 parser2 -- parser ) : <& ( parser1 parser2 -- parser )
#! Same as <&> except discard the results of the second parser. #! Same as <&> except discard the results of the second parser.
@ -272,7 +272,7 @@ LAZY: only-first ( parser -- parser )
M: only-first-parser parse ( input parser -- list ) M: only-first-parser parse ( input parser -- list )
#! Transform a parser into a parser that only yields #! Transform a parser into a parser that only yields
#! the first possibility. #! the first possibility.
only-first-parser-p1 parse 1 swap ltake ; p1>> parse 1 swap ltake ;
LAZY: <!*> ( parser -- parser ) LAZY: <!*> ( parser -- parser )
#! Like <*> but only return one possible result #! Like <*> but only return one possible result

View File

@ -105,11 +105,11 @@ IN: peg.ebnf.tests
] unit-test ] unit-test
{ "foo" } [ { "foo" } [
"foo" 'non-terminal' parse ebnf-non-terminal-symbol "foo" 'non-terminal' parse symbol>>
] unit-test ] unit-test
{ "foo" } [ { "foo" } [
"foo]" 'non-terminal' parse ebnf-non-terminal-symbol "foo]" 'non-terminal' parse symbol>>
] unit-test ] unit-test
{ V{ "a" "b" } } [ { V{ "a" "b" } } [

View File

@ -32,7 +32,7 @@ M: processing-gadget handle-gesture ( gesture gadget -- ? )
{ {
[ dup key-down? ] [ dup key-down? ]
[ [
key-down-sym key-value set sym>> key-value set
key-pressed-value on key-pressed-value on
key-down>> dup [ call ] [ drop ] if key-down>> dup [ call ] [ drop ] if
t t
@ -49,7 +49,7 @@ M: processing-gadget handle-gesture ( gesture gadget -- ? )
{ {
[ dup button-down? ] [ dup button-down? ]
[ [
button-down-# button-value set #>> button-value set
mouse-pressed-value on mouse-pressed-value on
button-down>> dup [ call ] [ drop ] if button-down>> dup [ call ] [ drop ] if
t t

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays ascii assocs hashtables io.encodings.ascii io.files kernel math USING: arrays ascii assocs hashtables io.encodings.ascii io.files kernel math
math.parser namespaces sequences sequences.lib sequences.private sorting math.parser namespaces sequences sequences.lib sequences.private sorting
splitting grouping strings sets ; splitting grouping strings sets accessors ;
IN: project-euler.059 IN: project-euler.059
! http://projecteuler.net/index.php?section=problems&id=59 ! http://projecteuler.net/index.php?section=problems&id=59
@ -60,9 +60,9 @@ TUPLE: rollover seq n ;
C: <rollover> rollover C: <rollover> rollover
M: rollover length rollover-n ; M: rollover length n>> ;
M: rollover nth-unsafe rollover-seq [ length mod ] keep nth-unsafe ; M: rollover nth-unsafe seq>> [ length mod ] keep nth-unsafe ;
INSTANCE: rollover immutable-sequence INSTANCE: rollover immutable-sequence

View File

@ -323,8 +323,8 @@ TUPLE: regexp source parser ignore-case? ;
M: regexp pprint* M: regexp pprint*
[ [
dup regexp-source dup source>>
dup find-regexp-syntax swap % swap % % dup find-regexp-syntax swap % swap % %
dup regexp-ignore-case? [ "i" % ] when dup ignore-case?>> [ "i" % ] when
] "" make ] "" make
swap present-text ; swap present-text ;

View File

@ -11,7 +11,7 @@ TUPLE: repeating circular len ;
: repeated ( seq length -- new-seq ) : repeated ( seq length -- new-seq )
dupd <repeating> swap like ; dupd <repeating> swap like ;
M: repeating length repeating-len ; M: repeating length len>> ;
M: repeating set-length (>>len) ; M: repeating set-length (>>len) ;
M: repeating virtual@ ( n seq -- n' seq' ) circular>> ; M: repeating virtual@ ( n seq -- n' seq' ) circular>> ;

View File

@ -61,7 +61,7 @@ IN: slides
: page-theme ( gadget -- ) : page-theme ( gadget -- )
T{ gradient f { T{ rgba f 0.8 0.8 1.0 1.0 } T{ rgba f 0.8 1.0 1.0 1.0 } } } T{ gradient f { T{ rgba f 0.8 0.8 1.0 1.0 } T{ rgba f 0.8 1.0 1.0 1.0 } } }
swap set-gadget-interior ; >>interior drop ;
: <page> ( list -- gadget ) : <page> ( list -- gadget )
[ [
@ -82,8 +82,8 @@ TUPLE: slides < book ;
[ <page> ] map 0 <model> slides new-book ; [ <page> ] map 0 <model> slides new-book ;
: change-page ( book n -- ) : change-page ( book n -- )
over control-value + over gadget-children length rem over control-value + over children>> length rem
swap gadget-model set-model ; swap model>> set-model ;
: next-page ( book -- ) 1 change-page ; : next-page ( book -- ) 1 change-page ;

View File

@ -52,13 +52,11 @@ DEFER: maybe-loop
: springies-window* ( -- ) : springies-window* ( -- )
C[ display ] <slate> >slate C[ display ] <slate>
{ 800 600 } slate> set-slate-pdim { 800 600 } >>pdim
C[ { 500 500 } >world-size loop on [ run ] in-thread ] C[ { 500 500 } >world-size loop on [ run ] in-thread ] >>graft
slate> set-slate-graft C[ loop off ] >>ungraft
C[ loop off ] slate> set-slate-ungraft [ >slate ] [ "Springies" open-window ] bi ;
slate> "Springies" open-window ;
: springies-window ( -- ) [ [ springies-window* ] with-scope ] with-ui ; : springies-window ( -- ) [ [ springies-window* ] with-scope ] with-ui ;

View File

@ -63,10 +63,8 @@ M: f text-matches?
M: string-matcher text-matches? M: string-matcher text-matches?
[ [
dup string-matcher-string [ string>> ] [ ignore-case?>> ] bi string-head?
swap string-matcher-ignore-case? ] keep string>> length and ;
string-head?
] keep string-matcher-string length and ;
M: regexp text-matches? M: regexp text-matches?
>r >string r> match-head ; >r >string r> match-head ;
@ -177,17 +175,17 @@ M: mark-following-rule handle-rule-start
?end-rule ?end-rule
mark-token add-remaining-token mark-token add-remaining-token
tuck rule-match-token* next-token, tuck rule-match-token* next-token,
f context get set-line-context-end f context get (>>end)
context get set-line-context-in-rule ; context get (>>in-rule) ;
M: mark-following-rule handle-rule-end M: mark-following-rule handle-rule-end
nip rule-match-token* prev-token, nip rule-match-token* prev-token,
f context get set-line-context-in-rule ; f context get (>>in-rule) ;
M: mark-previous-rule handle-rule-start M: mark-previous-rule handle-rule-start
?end-rule ?end-rule
mark-token mark-token
dup rule-body-token prev-token, dup body-token>> prev-token,
rule-match-token* next-token, ; rule-match-token* next-token, ;
: do-escaped ( -- ) : do-escaped ( -- )

View File

@ -97,7 +97,7 @@ GENERIC: text-hash-char ( text -- ch )
M: f text-hash-char ; M: f text-hash-char ;
M: string-matcher text-hash-char string-matcher-string first ; M: string-matcher text-hash-char string>> first ;
M: regexp text-hash-char drop f ; M: regexp text-hash-char drop f ;