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

db4
Slava Pestov 2008-11-13 17:45:53 -06:00
commit 174f24a1f3
7 changed files with 39 additions and 15 deletions

View File

@ -0,0 +1 @@
Kibleur Christophe

View File

@ -0,0 +1,18 @@
! Copyright (C) 2008 Kibleur Christophe.
! See http://factorcode.org/license.txt for BSD license.
USING: editors io.files io.launcher kernel math.parser
namespaces sequences windows.shell32 make ;
IN: editors.etexteditor
: etexteditor-path ( -- str )
\ etexteditor-path get-global [
program-files "e\\e.exe" append-path
] unless* ;
: etexteditor ( file line -- )
[
etexteditor-path ,
[ , ] [ "--line" , number>string , ] bi*
] { } make run-detached drop ;
[ etexteditor ] edit-hook set-global

View File

@ -0,0 +1 @@
etexteditor integration

View File

@ -0,0 +1 @@
unportable

View File

@ -13,17 +13,13 @@ GENERIC: seed-random ( tuple seed -- )
GENERIC: random-32* ( tuple -- r )
GENERIC: random-bytes* ( n tuple -- byte-array )
<PRIVATE
: adjust-random ( n m -- n' )
3 mask zero? [ 1+ ] unless ; inline
PRIVATE>
M: object random-bytes* ( n tuple -- byte-array )
[ [ 4 /i ] keep adjust-random ] dip
over 4 * <byte-vector>
[ '[ _ random-32* 4 >le _ push-all ] times ] keep ;
[ [ <byte-vector> ] keep 4 /mod ] dip tuck
[ pick '[ _ random-32* 4 >le _ push-all ] times ]
[
over zero?
[ 2drop ] [ random-32* 4 >le swap head over push-all ] if
] 2bi* ;
M: object random-32* ( tuple -- r ) 4 random-bytes* le> ;
@ -37,15 +33,13 @@ M: f random-bytes* ( n obj -- * ) no-random-number-generator ;
M: f random-32* ( obj -- * ) no-random-number-generator ;
: random-bytes ( n -- byte-array )
[
dup adjust-random random-generator get random-bytes*
] keep head-slice >byte-array ;
random-generator get random-bytes* ;
<PRIVATE
: random-integer ( n -- n' )
dup log2 7 + 8 /i 1+
[ random-bytes byte-array>bignum ]
[ random-bytes >byte-array byte-array>bignum ]
[ 3 shift 2^ ] bi / * >integer ;
PRIVATE>

View File

@ -27,7 +27,7 @@ ARTICLE: "inference-combinators" "Combinator stack effects"
"Consider a combinator such as " { $link keep } ". The combinator itself does not have a stack effect, because it applies " { $link call } " to a potentially arbitrary quotation. However, since the combinator is declared " { $link POSTPONE: inline } ", a given usage of it can have a stack effect:"
{ $example "[ [ 2 + ] keep ] infer." "( object -- object object )" }
"Another example is the " { $link compose } " combinator. Because it is decared " { $link POSTPONE: inline } ", we can infer the stack effect of applying " { $link call } " to the result of " { $link compose } ":"
{ $example "[ 2 [ + ] curry [ sq ] compose ] infer." "( -- object object )" }
{ $example "[ 2 [ + ] curry [ sq ] compose ] infer." "( -- object )" }
"Incidentally, this example demonstrates that the stack effect of nested currying and composition can also be inferred."
$nl
"A general rule of thumb is that any word which applies " { $link call } " or " { $link curry } " to one of its inputs must be declared " { $link POSTPONE: inline } "."

View File

@ -263,3 +263,12 @@ SYMBOL: examples-flag
[ example ] times
"}" print
] with-variable ;
: scaffold-rc ( path -- )
[ touch-file ] [ "Click to edit: " write <pathname> . ] bi ;
: scaffold-factor-boot-rc ( -- )
home ".factor-boot-rc" append-path scaffold-rc ;
: scaffold-factor-rc ( -- )
home ".factor-rc" append-path scaffold-rc ;