image-path :> image
[
- I[
+ [I
#include <vm/master.h>
#include <stdio.h>
#include <stdbool.h>
printf("Done.\n");
return 0;
}
- ]I
+ I]
] with-string-writer
[ compile-file ] with-temp-directory
[ run-test ] with-temp-directory ;
{ $var-description "Bootstrap architecture name" } ;
HELP: bootstrap-startup-quot
-{ $var-description "This image's startup quotation or " { $link f } ". "} ;
+{ $var-description "This image's startup quotation or " { $link f } ". " } ;
HELP: define-sub-primitive
{ $values { "quot" quotation } { "word" word } }
}
} [
3 D 0 replace-loc [
- "eh",
+ "eh" ,
replaces get height-state get emit-changes
] V{ } make
] cfg-unit-test
M: textedit editor-command ( file line -- command )
drop
- [ "open" , "-a" , "TextEdit", , ] { } make ;
+ [ "open" , "-a" , "TextEdit" , , ] { } make ;
CONSTANT: key-space 0x002c
CONSTANT: key-- 0x002d
CONSTANT: key-= 0x002e
-CONSTANT: key-[ 0x002f
-CONSTANT: key-] 0x0030
+CONSTANT: key-lbracket 0x002f
+CONSTANT: key-rbracket 0x0030
CONSTANT: key-\ 0x0031
CONSTANT: key-#-non-us 0x0032
CONSTANT: key-; 0x0033
"[ + + + ]"
}
}
-{ $description "Construct a quotation containing the contents of " { $snippet "seq" } " repeated " { $snippet "n"} " times." } ;
+{ $description "Construct a quotation containing the contents of " { $snippet "seq" } " repeated " { $snippet "n" } " times." } ;
ARTICLE: "shuffle-generalizations" "Generalized shuffle words"
{ $subsections
: xml>type ( xml -- type )
dup name>> main>> {
{ "type" [ xml>simple-type ] }
- { "array"[ xml>array-type ] }
+ { "array" [ xml>array-type ] }
{ "callback" [ xml>inner-callback-type ] }
{ "varargs" [ xml>varargs-type ] }
} case ;
"Now if you press " { $command tool "common" refresh-all } ", the source file should reload without any errors. You can run unit tests again, and this time, they will all pass:"
{ $code "\"palindrome\" test" }
$nl
-"Congratulations, you have now completed " { $link "first-program" } "!";
+"Congratulations, you have now completed " { $link "first-program" } "!" ;
ARTICLE: "first-program" "Your first program"
"In this tutorial, we will write a simple Factor program which prompts the user to enter a word, and tests if it is a palindrome (that is, the word is spelled the same backwards and forwards)."
{ "Oops, I accidentally the whole economy..." } [
[let
"economy" :> noun
- "accidentally" [ I[ Oops, I ${0} the whole ${noun}...]I ] with-string-writer
+ "accidentally" [ [I Oops, I ${0} the whole ${noun}...I] ] with-string-writer
]
] unit-test
: interpolate-locals ( str -- quot )
[ dup search [ [ ] ] [ [ get ] ] ?if ] interpolate-quot ;
-SYNTAX: I[
- "]I" parse-multiline-string
+SYNTAX: [I
+ "I]" parse-multiline-string
interpolate-locals append! ;
IN: math.statistics
HELP: geometric-mean
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the geometric mean of all elements in " { $snippet "seq" } ". The geometric mean measures the central tendency of a data set and minimizes the effects of extreme values." }
{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } geometric-mean ." "1.81712059283214" } }
{ $errors "Throws a " { $link signal-error. } " (square-root of 0) if the sequence is empty." } ;
HELP: harmonic-mean
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the harmonic mean of the elements in " { $snippet "seq" } ". The harmonic mean is appropriate when the average of rates is desired." }
{ $notes "Positive reals only." }
{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } harmonic-mean ." "6/11" } }
{ $examples { $example "USING: math.statistics prettyprint ;" "{ 3 1 2 } 1 kth-smallest ." "2" } } ;
HELP: mean
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the arithmetic mean of the elements in " { $snippet "seq" } "." }
{ $examples { $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } mean ." "2" } }
{ $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ;
HELP: median
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the median of " { $snippet "seq" } " by finding the middle element of the sequence using " { $link kth-smallest } ". If there is an even number of elements in the sequence, the median is not unique, so the mean of the two middle values is output." }
{ $examples
{ $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } median ." "2" }
{ $errors "Throws a " { $link signal-error. } " (divide by zero) if the sequence is empty." } ;
HELP: range
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the difference of the maximum and minimum values in " { $snippet "seq" } "." }
{ $examples
{ $example "USING: math.statistics prettyprint ;" "{ 1 2 3 } range ." "2" }
} ;
HELP: sample-std
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the sample standard deviation of " { $snippet "seq" } ", which is the square root of the sample variance. It measures how widely spread the values in a sequence are about the mean for a random subset of a dataset." }
{ $examples
{ $example "USING: math.statistics prettyprint ;" "{ 7 8 9 } sample-std ." "1.0" } } ;
HELP: sample-ste
- { $values { "seq" sequence } { "x" "a non-negative real number"} }
+ { $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the standard error of the mean for " { $snippet "seq" } ". It's defined as the standard deviation divided by the square root of the length of the sequence, and measures uncertainty associated with the estimate of the mean." }
{ $examples
{ $example "USING: math.statistics prettyprint ;" "{ -2 2 } sample-ste ." "2.0" }
} ;
HELP: sample-var
-{ $values { "seq" sequence } { "x" "a non-negative real number"} }
+{ $values { "seq" sequence } { "x" "a non-negative real number" } }
{ $description "Computes the variance of " { $snippet "seq" } ". It's a measurement of the spread of values in a sequence." }
{ $notes "If the number of elements in " { $snippet "seq" } " is 1 or less, it outputs 0." }
{ $examples
{ $description "Binds texture " { $snippet "id" } " to texture target " { $snippet "target" } " of texture unit " { $snippet "unit" } ". Equivalent to " { $snippet "unit glActiveTexture target id glBindTexture" } "." } ;
HELP: set-draw-buffers
-{ $values { "buffers" "A sequence of buffer words (e.g. " { $snippet "GL_BACK" } ", " { $snippet "GL_COLOR_ATTACHMENT0" } ")"} }
+{ $values { "buffers" "A sequence of buffer words (e.g. " { $snippet "GL_BACK" } ", " { $snippet "GL_COLOR_ATTACHMENT0" } ")" } }
{ $description "Wrapper for " { $link glDrawBuffers } ". Sets up the buffers named in the sequence for simultaneous drawing." } ;
HELP: do-attribs
HELP: vertex-shader
{ $class-description { $snippet "vertex-shader" } " is the predicate class of " { $link gl-shader } " objects that refer to shaders of type " { $snippet "GL_VERTEX_SHADER" } ". In addition to the " { $snippet "gl-shader" } " words, the following vertex shader-specific functions are defined:"
{ $list
- { { $link <vertex-shader> } " - Compile GLSL code into a vertex shader object "}
+ { { $link <vertex-shader> } " - Compile GLSL code into a vertex shader object " }
}
} ;
HELP: fragment-shader
{ $class-description { $snippet "fragment-shader" } " is the predicate class of " { $link gl-shader } " objects that refer to shaders of type " { $snippet "GL_FRAGMENT_SHADER" } ". In addition to the " { $snippet "gl-shader" } " words, the following fragment shader-specific functions are defined:"
{ $list
- { { $link <fragment-shader> } " - Compile GLSL code into a fragment shader object "}
+ { { $link <fragment-shader> } " - Compile GLSL code into a fragment shader object " }
}
} ;
} { $description
"Returns a parser that matches n or more repetitions of the input parser."
} { $examples
- { $code "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 at-least-n parse => exception"}
+ { $code "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 at-least-n parse => exception" }
{ $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-least-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" }
{ $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-least-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" \"a\" }" }
} { $see-also exactly-n at-most-n from-m-to-n } ;
"range of characters from the first to the second, inclusive."
{ $examples
{ $example "USING: peg peg.parsers prettyprint strings ;" "\"a\" \"_a-zA-Z\" range-pattern parse 1string ." "\"a\"" }
- { $code "USING: peg peg.parsers prettyprint ;\n\"0\" \"^0-9\" range-pattern parse => exception"}
+ { $code "USING: peg peg.parsers prettyprint ;\n\"0\" \"^0-9\" range-pattern parse => exception" }
}
} ;
"Tokenize a string. Supported syntax:"
{ $list
{ { $snippet "foo bar baz" } " - simple tokens" }
- { { $snippet "foo\\ bar" } " - token with an escaped space"}
+ { { $snippet "foo\\ bar" } " - token with an escaped space" }
{ { $snippet "\"foo bar\"" } " - quoted token" }
}
} ;
{ $description "Creates a new string with the given length and all characters initially set to " { $snippet "ch" } "." } ;
HELP: 1string
-{ $values { "ch" "a character"} { "str" string } }
+{ $values { "ch" "a character" } { "str" string } }
{ $description "Outputs a string of one character." } ;
HELP: >string
;
HELP: cut-amb
-{ $description "Reset the amb system. Calling this word resets the whole stack of " { $link amb } " calls and should not be done lightly."}
+{ $description "Reset the amb system. Calling this word resets the whole stack of " { $link amb } " calls and should not be done lightly." }
{ $see-also amb fail }
;
{ key-i { { 85 25 } { 10 10 } } }
{ key-o { { 95 25 } { 10 10 } } }
{ key-p { { 105 25 } { 10 10 } } }
- { key-[ { { 115 25 } { 10 10 } } }
- { key-] { { 125 25 } { 10 10 } } }
+ { key-lbracket { { 115 25 } { 10 10 } } }
+ { key-rbracket { { 125 25 } { 10 10 } } }
{ key-\ { { 135 25 } { 15 10 } } }
{ key-caps-lock { { 0 35 } { 20 10 } } }
{ $description "Removes the connection between the gadget and it's model" } ;
ARTICLE: "images.viewer" "Displaying Images"
"The " { $vocab-link "images.viewer" } " vocabulary uses the " { $vocab-link "opengl.textures" }
-" vocabulary to display any instance of " { $link image } "."$nl
+" vocabulary to display any instance of " { $link image } "." $nl
"An " { $link image-gadget } " can be used for static images and " { $instance image-control }
" for changing images (for example a video feed). For changing images, the image should be contained in " { $instance model }
". Change the model value with " { $link set-model } " or mutate the image and call "
] unit-test
] spawning-irc
-[ { join_ "#factortest"} [
+[ { join_ "#factortest" } [
"#factortest" <irc-channel-chat> [ %add-named-chat ] keep
{ ":factorbot!n=factorbo@some.where JOIN :#factortest"
":ircserver.net 353 factorbot @ #factortest :@factorbot "
ARTICLE: "math.dual" "Dual Numbers"
"The " { $vocab-link "math.dual" } " vocabulary implements dual numbers, along with arithmetic methods for working with them. Many of the functions in " { $vocab-link "math.functions" } " are extended to work with dual numbers."
$nl
-"Dual numbers are ordered pairs " { $snippet "<o,e>"} "--an ordinary part and an epsilon part--with component-wise addition and multiplication defined by "{ $snippet "<o1,e1>*<o2,e2> = <o1*o2,e1*o2 + e2*o1>" } ". They are analagous to complex numbers with " { $snippet "i^2 = 0" } "instead of " { $snippet "i^2 = -1" } ". For well-behaved functions " { $snippet "f" } ", " { $snippet "f(<o1,e1>) = f(o1) + e1*f'(o1)" } ", where " { $snippet "f'"} " is the derivative of " { $snippet "f" } "."
+"Dual numbers are ordered pairs " { $snippet "<o,e>" } "--an ordinary part and an epsilon part--with component-wise addition and multiplication defined by " { $snippet "<o1,e1>*<o2,e2> = <o1*o2,e1*o2 + e2*o1>" } ". They are analagous to complex numbers with " { $snippet "i^2 = 0" } "instead of " { $snippet "i^2 = -1" } ". For well-behaved functions " { $snippet "f" } ", " { $snippet "f(<o1,e1>) = f(o1) + e1*f'(o1)" } ", where " { $snippet "f'" } " is the derivative of " { $snippet "f" } "."
;
ABOUT: "math.dual"
{ $description "Creates a sequence of cubic hermite curves (each a sequence of polynomials) passing through the given points, generating tangents with the given tuning parameters." } ;
ARTICLE: "math.splines" "Common parametric curves."
-"The curve creating functions create sequences of polynomials, one for each degree of the input points. The spline creating functions create sequences of these curve polynomial sequences. The " { $vocab-link "math.splines.viewer" } " vocabulary provides a gadget to evaluate the generated polynomials and view the results.";
+"The curve creating functions create sequences of polynomials, one for each degree of the input points. The spline creating functions create sequences of these curve polynomial sequences. The " { $vocab-link "math.splines.viewer" } " vocabulary provides a gadget to evaluate the generated polynomials and view the results." ;
ABOUT: "math.splines"
HELP: cl-platforms
{ $values
- { "platforms" "sequence of cl-platform"}
+ { "platforms" "sequence of cl-platform" }
}
{ $description "Returns the platforms available for OpenCL computation on this hardware." } ;
HELP: breset
{ $values { "quot" { $quotation ( r -- v ) } } }
-{ $description "Marks the boundary of the partial continuation. The quotation has stack effect " { $snippet "( r -- v )" } ", where " { $snippet "r" } " identifies the " { $link breset } " in scope and should be passed to "{ $link bshift } " to mark the boundary of the continuation." }
+{ $description "Marks the boundary of the partial continuation. The quotation has stack effect " { $snippet "( r -- v )" } ", where " { $snippet "r" } " identifies the " { $link breset } " in scope and should be passed to " { $link bshift } " to mark the boundary of the continuation." }
{ $notes "It is important to note that even if the quotation discards items on the stack, the stack will be restored to the way it was before it is called (which is true of continuation usage in general)." } ;
HELP: bshift
{ "seq" "a sequence of " { $link bucket } " objects" }
}
{ $description
- "Returns a list of " { $link bucket } " objects containing data on the buckets available on S3."}
+ "Returns a list of " { $link bucket } " objects containing data on the buckets available on S3." }
{ $examples
{ $unchecked-example "USING: s3 ;" "buckets ." "{ }" }
}
HELP: keys
{ $values
{ "bucket" string }
- { "seq" "a sequence of " { $link key } " objects"}
+ { "seq" "a sequence of " { $link key } " objects" }
}
{ $description
"Returns a sequence of " { $link key } " objects. Each object in the sequence has information about the keys contained within the bucket."
{ $values
{ "bucket" string }
{ "key" string }
- { "response" "The HTTP response object"}
- { "data" "The data returned from the http request"}
+ { "response" "The HTTP response object" }
+ { "data" "The data returned from the http request" }
}
{ $description
"Does an HTTP request to retrieve the object in the bucket with the given key."