Merge branch 'master' of git://factorcode.org/git/factor
commit
7676e0b727
|
@ -2,7 +2,7 @@ USING: tools.test io.files io.files.temp io.pathnames
|
||||||
io.directories io.files.info io.files.info.unix continuations
|
io.directories io.files.info io.files.info.unix continuations
|
||||||
kernel io.files.unix math.bitwise calendar accessors
|
kernel io.files.unix math.bitwise calendar accessors
|
||||||
math.functions math unix.users unix.groups arrays sequences
|
math.functions math unix.users unix.groups arrays sequences
|
||||||
grouping ;
|
grouping io.pathnames.private ;
|
||||||
IN: io.files.unix.tests
|
IN: io.files.unix.tests
|
||||||
|
|
||||||
[ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test
|
[ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: io.files io.pathnames kernel tools.test io.backend
|
USING: io.files io.pathnames kernel tools.test io.backend
|
||||||
io.files.windows.nt splitting sequences ;
|
io.files.windows.nt splitting sequences io.pathnames.private ;
|
||||||
IN: io.files.windows.nt.tests
|
IN: io.files.windows.nt.tests
|
||||||
|
|
||||||
[ f ] [ "\\foo" absolute-path? ] unit-test
|
[ f ] [ "\\foo" absolute-path? ] unit-test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: help.markup help.syntax io.backend io.files io.directories strings
|
USING: help.markup help.syntax io.backend io.files io.directories strings
|
||||||
sequences ;
|
sequences io.pathnames.private ;
|
||||||
IN: io.pathnames
|
IN: io.pathnames
|
||||||
|
|
||||||
HELP: path-separator?
|
HELP: path-separator?
|
||||||
|
@ -46,12 +46,24 @@ HELP: path-components
|
||||||
{ $description "Splits a pathname on the " { $link path-separator } " into its its component strings." } ;
|
{ $description "Splits a pathname on the " { $link path-separator } " into its its component strings." } ;
|
||||||
|
|
||||||
HELP: append-path
|
HELP: append-path
|
||||||
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
{ $values { "path1" "a pathname string" } { "path2" "a pathname string" } { "path" "a pathname string" } }
|
||||||
{ $description "Appends " { $snippet "str1" } " and " { $snippet "str2" } " to form a pathname." } ;
|
{ $description "Appends " { $snippet "path1" } " and " { $snippet "path2" } " to form a pathname." }
|
||||||
|
{ $examples
|
||||||
|
{ $unchecked-example """USING: io.pathnames prettyprint ;
|
||||||
|
"first" "second.txt" append-path ."""
|
||||||
|
"first/second.txt"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
HELP: prepend-path
|
HELP: prepend-path
|
||||||
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
{ $values { "path1" "a pathname string" } { "path2" "a pathname string" } { "path" "a pathname string" } }
|
||||||
{ $description "Appends " { $snippet "str2" } " and " { $snippet "str1" } " to form a pathname." } ;
|
{ $description "Appends " { $snippet "path2" } " and " { $snippet "path1" } " to form a pathname." }
|
||||||
|
{ $examples
|
||||||
|
{ $unchecked-example """USING: io.pathnames prettyprint ;
|
||||||
|
"second.txt" "first" prepend-path ."""
|
||||||
|
"first/second.txt"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
{ append-path prepend-path } related-words
|
{ append-path prepend-path } related-words
|
||||||
|
|
||||||
|
@ -77,9 +89,10 @@ HELP: pathname
|
||||||
{ $class-description "Class of path name objects. Path name objects can be created by calling " { $link <pathname> } "." } ;
|
{ $class-description "Class of path name objects. Path name objects can be created by calling " { $link <pathname> } "." } ;
|
||||||
|
|
||||||
HELP: normalize-path
|
HELP: normalize-path
|
||||||
{ $values { "str" "a pathname string" } { "newstr" "a new pathname string" } }
|
{ $values { "string" "a pathname string" } { "string'" "a new pathname string" } }
|
||||||
{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " prefix, if present, and performs any platform-specific pathname normalization." }
|
{ $description "Prepends the " { $link current-directory } " to the pathname, resolves a " { $snippet "resource:" } " or " { $snippet "voacb:" } " prefix, if present, and performs any platform-specific pathname normalization." }
|
||||||
{ $notes "High-level words, such as " { $link <file-reader> } " and " { $link delete-file } " call this word for you. It only needs to be called directly when passing pathnames to C functions or external processes. This is because Factor does not use the operating system's notion of a current directory, and instead maintains its own dynamically-scoped " { $link current-directory } " variable." }
|
{ $notes "High-level words, such as " { $link <file-reader> } " and " { $link delete-file } " call this word for you. It only needs to be called directly when passing pathnames to C functions or external processes. This is because Factor does not use the operating system's notion of a current directory, and instead maintains its own dynamically-scoped " { $link current-directory } " variable." }
|
||||||
|
{ $notes "On Windows NT platforms, this word does prepends the Unicode path prefix." }
|
||||||
{ $examples
|
{ $examples
|
||||||
"For example, if you create a file named " { $snippet "data.txt" } " in the current directory, and wish to pass it to a process, you must normalize it:"
|
"For example, if you create a file named " { $snippet "data.txt" } " in the current directory, and wish to pass it to a process, you must normalize it:"
|
||||||
{ $code
|
{ $code
|
||||||
|
@ -88,9 +101,18 @@ HELP: normalize-path
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
HELP: (normalize-path)
|
||||||
|
{ $values
|
||||||
|
{ "path" "a pathname string" }
|
||||||
|
{ "path'" "a pathname string" }
|
||||||
|
}
|
||||||
|
{ $description "Prepends the " { $link current-directory } " to the pathname and resolves a " { $snippet "resource:" } " prefix, if present." }
|
||||||
|
{ $notes "On Windows NT platforms, this word does not prepend the Unicode path prefix." } ;
|
||||||
|
|
||||||
HELP: canonicalize-path
|
HELP: canonicalize-path
|
||||||
{ $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
|
{ $values { "path" "a pathname string" } { "path'" "a new pathname string" } }
|
||||||
{ $description "Returns an canonical name for a path. The canonical name is an absolute path containing no symlinks." } ;
|
{ $description "Outputs a path where none of the path components are symlinks. This word is useful for determining the actual path on disk where a file is stored; the root of this absolute path is a mount point in the file-system." }
|
||||||
|
{ $notes "Most code should not need to call this word except in very special circumstances. One use case is finding the actual file-system on which a file is stored." } ;
|
||||||
|
|
||||||
HELP: <pathname>
|
HELP: <pathname>
|
||||||
{ $values { "string" "a pathname string" } { "pathname" pathname } }
|
{ $values { "string" "a pathname string" } { "pathname" pathname } }
|
||||||
|
@ -98,20 +120,28 @@ HELP: <pathname>
|
||||||
|
|
||||||
HELP: home
|
HELP: home
|
||||||
{ $values { "dir" string } }
|
{ $values { "dir" string } }
|
||||||
{ $description "Outputs the user's home directory." } ;
|
{ $description "Outputs the user's home directory." }
|
||||||
|
{ $examples
|
||||||
|
{ $unchecked-example "USING: io.pathnames prettyprint ;"
|
||||||
|
"home ."
|
||||||
|
"/home/factor-user"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
ARTICLE: "io.pathnames" "Pathname manipulation"
|
ARTICLE: "io.pathnames" "Pathnames"
|
||||||
"Pathname manipulation:"
|
"Pathnames are objects that contain a string representing the path to a file on disk. Pathnames are cross-platform; Windows accepts both forward and backward slashes as directory separators and new separators are added as a forward slash on all platforms. Clicking a pathname object in the UI brings up the file in one of the supported editors, but otherwise, pathnames and strings are interchangeable. See " { $link "editor" } " for more details." $nl
|
||||||
|
"Pathname introspection:"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
parent-directory
|
parent-directory
|
||||||
file-name
|
file-name
|
||||||
file-stem
|
file-stem
|
||||||
file-extension
|
file-extension
|
||||||
last-path-separator
|
|
||||||
path-components
|
path-components
|
||||||
|
}
|
||||||
|
"Appending pathnames:"
|
||||||
|
{ $subsections
|
||||||
prepend-path
|
prepend-path
|
||||||
append-path
|
append-path
|
||||||
canonicalize-path
|
|
||||||
}
|
}
|
||||||
"Pathname presentations:"
|
"Pathname presentations:"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
|
@ -120,7 +150,11 @@ ARTICLE: "io.pathnames" "Pathname manipulation"
|
||||||
}
|
}
|
||||||
"Literal pathnames:"
|
"Literal pathnames:"
|
||||||
{ $subsections POSTPONE: P" }
|
{ $subsections POSTPONE: P" }
|
||||||
"Low-level word:"
|
"Low-level words:"
|
||||||
{ $subsections normalize-path } ;
|
{ $subsections
|
||||||
|
normalize-path
|
||||||
|
(normalize-path)
|
||||||
|
canonicalize-path
|
||||||
|
} ;
|
||||||
|
|
||||||
ABOUT: "io.pathnames"
|
ABOUT: "io.pathnames"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: io.pathnames io.files.temp io.directories
|
USING: io.pathnames io.files.temp io.directories
|
||||||
continuations math io.files.private kernel
|
continuations math io.files.private kernel
|
||||||
namespaces tools.test ;
|
namespaces tools.test io.pathnames.private ;
|
||||||
IN: io.pathnames.tests
|
IN: io.pathnames.tests
|
||||||
|
|
||||||
[ "passwd" ] [ "/etc/passwd" file-name ] unit-test
|
[ "passwd" ] [ "/etc/passwd" file-name ] unit-test
|
||||||
|
|
|
@ -10,10 +10,10 @@ SYMBOL: current-directory
|
||||||
|
|
||||||
: path-separator ( -- string ) os windows? "\\" "/" ? ;
|
: path-separator ( -- string ) os windows? "\\" "/" ? ;
|
||||||
|
|
||||||
: trim-tail-separators ( str -- newstr )
|
: trim-tail-separators ( string -- string' )
|
||||||
[ path-separator? ] trim-tail ;
|
[ path-separator? ] trim-tail ;
|
||||||
|
|
||||||
: trim-head-separators ( str -- newstr )
|
: trim-head-separators ( string -- string' )
|
||||||
[ path-separator? ] trim-head ;
|
[ path-separator? ] trim-head ;
|
||||||
|
|
||||||
: last-path-separator ( path -- n ? )
|
: last-path-separator ( path -- n ? )
|
||||||
|
@ -61,8 +61,6 @@ ERROR: no-parent-directory path ;
|
||||||
[ nip ]
|
[ nip ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
: windows-absolute-path? ( path -- path ? )
|
: windows-absolute-path? ( path -- path ? )
|
||||||
{
|
{
|
||||||
{ [ dup "\\\\?\\" head? ] [ t ] }
|
{ [ dup "\\\\?\\" head? ] [ t ] }
|
||||||
|
@ -87,7 +85,9 @@ PRIVATE>
|
||||||
[ f ]
|
[ f ]
|
||||||
} cond nip ;
|
} cond nip ;
|
||||||
|
|
||||||
: append-path ( str1 str2 -- str )
|
PRIVATE>
|
||||||
|
|
||||||
|
: append-path ( path1 path2 -- path )
|
||||||
{
|
{
|
||||||
{ [ over empty? ] [ append-path-empty ] }
|
{ [ over empty? ] [ append-path-empty ] }
|
||||||
{ [ dup empty? ] [ drop ] }
|
{ [ dup empty? ] [ drop ] }
|
||||||
|
@ -107,7 +107,7 @@ PRIVATE>
|
||||||
]
|
]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
: prepend-path ( str1 str2 -- str )
|
: prepend-path ( path1 path2 -- path )
|
||||||
swap append-path ; inline
|
swap append-path ; inline
|
||||||
|
|
||||||
: file-name ( path -- string )
|
: file-name ( path -- string )
|
||||||
|
|
|
@ -574,7 +574,7 @@ HELP: SBUF"
|
||||||
HELP: P"
|
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. Pathnames presented in the UI are clickable, which opens them in a text editor configured with " { $link "editor" } "." }
|
||||||
{ $examples { $example "USING: accessors io io.files ;" "P\" foo.txt\" string>> print" "foo.txt" } } ;
|
{ $examples { $example "USING: accessors io io.files ;" "P\" foo.txt\" string>> print" "foo.txt" } } ;
|
||||||
|
|
||||||
HELP: (
|
HELP: (
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
! Copyright (C) 2009 Doug Coleman.
|
! Copyright (C) 2009 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays kernel random random.cmwc sequences tools.test ;
|
USING: alien.c-types arrays kernel random random.cmwc sequences
|
||||||
|
specialized-arrays specialized-arrays.instances.uint tools.test ;
|
||||||
IN: random.cmwc.tests
|
IN: random.cmwc.tests
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
@ -24,18 +25,18 @@ IN: random.cmwc.tests
|
||||||
}
|
}
|
||||||
] [
|
] [
|
||||||
cmwc-4096
|
cmwc-4096
|
||||||
4096 iota >array 362436 <cmwc-seed> seed-random [
|
4096 iota >uint-array 362436 <cmwc-seed> seed-random [
|
||||||
10 [ random-32 ] replicate
|
10 [ random-32 ] replicate
|
||||||
] with-random
|
] with-random
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ t ] [
|
[ t ] [
|
||||||
cmwc-4096 [
|
cmwc-4096 [
|
||||||
4096 iota >array 362436 <cmwc-seed> seed-random [
|
4096 iota >uint-array 362436 <cmwc-seed> seed-random [
|
||||||
10 [ random-32 ] replicate
|
10 [ random-32 ] replicate
|
||||||
] with-random
|
] with-random
|
||||||
] [
|
] [
|
||||||
4096 iota >array 362436 <cmwc-seed> seed-random [
|
4096 iota >uint-array 362436 <cmwc-seed> seed-random [
|
||||||
10 [ random-32 ] replicate
|
10 [ random-32 ] replicate
|
||||||
] with-random
|
] with-random
|
||||||
] bi =
|
] bi =
|
||||||
|
|
|
@ -1,28 +1,34 @@
|
||||||
! Copyright (C) 2009 Doug Coleman.
|
! Copyright (C) 2009 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays fry kernel locals math math.bitwise
|
USING: accessors alien.c-types arrays fry kernel locals math
|
||||||
random sequences ;
|
math.bitwise random sequences sequences.private
|
||||||
|
specialized-arrays specialized-arrays.instances.uint ;
|
||||||
IN: random.cmwc
|
IN: random.cmwc
|
||||||
|
|
||||||
! Multiply-with-carry RNG
|
! Multiply-with-carry RNG
|
||||||
|
|
||||||
TUPLE: cmwc Q a b c i r mod ;
|
TUPLE: cmwc
|
||||||
|
{ Q uint-array }
|
||||||
|
{ a fixnum }
|
||||||
|
{ b fixnum }
|
||||||
|
{ c fixnum }
|
||||||
|
{ i fixnum }
|
||||||
|
{ r fixnum }
|
||||||
|
{ mod fixnum } ;
|
||||||
|
|
||||||
TUPLE: cmwc-seed Q c ;
|
TUPLE: cmwc-seed { Q uint-array read-only } { c read-only } ;
|
||||||
|
|
||||||
: <cmwc> ( length a b c -- cmwc )
|
: <cmwc> ( length a b c -- cmwc )
|
||||||
cmwc new
|
cmwc new
|
||||||
swap >>c
|
swap >>c
|
||||||
swap >>b
|
swap >>b
|
||||||
swap >>a
|
swap >>a
|
||||||
swap [ 1 - >>i ] [ 0 <array> >>Q ] bi
|
swap [ 1 - >>i ] [ <uint-array> >>Q ] bi
|
||||||
dup b>> 1 - >>r
|
dup b>> 1 - >>r
|
||||||
dup Q>> length 1 - >>mod ;
|
dup Q>> length 1 - >>mod ; inline
|
||||||
|
|
||||||
: <cmwc-seed> ( Q c -- cmwc-seed )
|
: <cmwc-seed> ( Q c -- cmwc-seed )
|
||||||
cmwc-seed new
|
cmwc-seed boa ; inline
|
||||||
swap >>c
|
|
||||||
swap >>Q ; inline
|
|
||||||
|
|
||||||
M: cmwc seed-random
|
M: cmwc seed-random
|
||||||
[ Q>> >>Q ]
|
[ Q>> >>Q ]
|
||||||
|
@ -32,23 +38,25 @@ M: cmwc seed-random
|
||||||
M:: cmwc random-32* ( cmwc -- n )
|
M:: cmwc random-32* ( cmwc -- n )
|
||||||
cmwc dup mod>> '[ 1 + _ bitand ] change-i
|
cmwc dup mod>> '[ 1 + _ bitand ] change-i
|
||||||
[ a>> ]
|
[ a>> ]
|
||||||
[ [ i>> ] [ Q>> ] bi nth * ]
|
[ [ i>> ] [ Q>> ] bi nth-unsafe * ]
|
||||||
[ c>> + ] tri :> t!
|
[ c>> + ] tri
|
||||||
|
|
||||||
t -32 shift cmwc (>>c)
|
[ >fixnum -32 shift cmwc (>>c) ]
|
||||||
|
[ cmwc [ b>> bitand ] [ c>> + ] bi 32 bits ] bi
|
||||||
|
|
||||||
t cmwc [ b>> bitand ] [ c>> + ] bi 64 bits t!
|
dup cmwc r>> > [
|
||||||
t cmwc r>> > [
|
|
||||||
cmwc [ 1 + ] change-c drop
|
cmwc [ 1 + ] change-c drop
|
||||||
t cmwc b>> - 64 bits t!
|
cmwc b>> - 32 bits
|
||||||
] when
|
] when
|
||||||
|
|
||||||
cmwc [ r>> t - 32 bits dup ] [ i>> ] [ Q>> ] tri set-nth ;
|
cmwc swap '[ r>> _ - 32 bits dup ] [ i>> ] [ Q>> ] tri set-nth-unsafe ;
|
||||||
|
|
||||||
: cmwc-4096 ( -- cmwc )
|
: cmwc-4096 ( -- cmwc )
|
||||||
4096
|
4096
|
||||||
[ 18782 4294967295 362436 <cmwc> ]
|
[ 18782 4294967295 362436 <cmwc> ]
|
||||||
[
|
[
|
||||||
'[ [ random-32 ] replicate ] with-system-random
|
'[ [ random-32 ] uint-array{ } replicate-as ] with-system-random
|
||||||
362436 <cmwc-seed> seed-random
|
362436 <cmwc-seed> seed-random
|
||||||
] bi ;
|
] bi ;
|
||||||
|
|
||||||
|
: default-cmwc ( -- cmwc ) cmwc-4096 ;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
! Copyright (C) 2009 Doug Coleman.
|
! Copyright (C) 2009 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types fry kernel literals locals math
|
USING: accessors alien.c-types fry kernel literals locals math
|
||||||
random sequences specialized-arrays namespaces ;
|
random sequences specialized-arrays namespaces sequences.private ;
|
||||||
SPECIALIZED-ARRAY: double
|
SPECIALIZED-ARRAY: double
|
||||||
IN: random.lagged-fibonacci
|
IN: random.lagged-fibonacci
|
||||||
|
|
||||||
TUPLE: lagged-fibonacci u pt0 pt1 ;
|
TUPLE: lagged-fibonacci { u double-array } { pt0 fixnum } { pt1 fixnum } ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ CONSTANT: lagged-fibonacci-max-seed 900000000
|
||||||
CONSTANT: lagged-fibonacci-sig-bits 24
|
CONSTANT: lagged-fibonacci-sig-bits 24
|
||||||
|
|
||||||
: normalize-seed ( seed -- seed' )
|
: normalize-seed ( seed -- seed' )
|
||||||
abs lagged-fibonacci-max-seed mod ;
|
abs lagged-fibonacci-max-seed mod ; inline
|
||||||
|
|
||||||
: adjust-ptr ( ptr -- ptr' )
|
: adjust-ptr ( ptr -- ptr' )
|
||||||
1 - dup 0 < [ drop p-r ] when ;
|
1 - dup 0 < [ drop p-r ] when ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
@ -50,22 +50,26 @@ M:: lagged-fibonacci seed-random ( lagged-fibonacci seed! -- lagged-fibonacci )
|
||||||
s
|
s
|
||||||
] change-each
|
] change-each
|
||||||
lagged-fibonacci p-r >>pt0
|
lagged-fibonacci p-r >>pt0
|
||||||
q-r >>pt1 ;
|
q-r >>pt1 ; inline
|
||||||
|
|
||||||
: <lagged-fibonacci> ( seed -- lagged-fibonacci )
|
: <lagged-fibonacci> ( seed -- lagged-fibonacci )
|
||||||
lagged-fibonacci new
|
lagged-fibonacci new
|
||||||
p-r 1 + <double-array> >>u
|
p-r 1 + <double-array> >>u
|
||||||
swap seed-random ;
|
swap seed-random ; inline
|
||||||
|
|
||||||
GENERIC: random-float* ( tuple -- r )
|
GENERIC: random-float* ( tuple -- r )
|
||||||
|
|
||||||
: random-float ( -- n ) random-generator get random-float* ;
|
: random-float ( -- n ) random-generator get random-float* ; inline
|
||||||
|
|
||||||
M:: lagged-fibonacci random-float* ( lagged-fibonacci -- x )
|
M:: lagged-fibonacci random-float* ( lagged-fibonacci -- x )
|
||||||
lagged-fibonacci [ pt0>> ] [ u>> ] bi nth
|
lagged-fibonacci [ pt0>> ] [ u>> ] bi nth-unsafe
|
||||||
lagged-fibonacci [ pt1>> ] [ u>> ] bi nth - :> uni!
|
lagged-fibonacci [ pt1>> ] [ u>> ] bi nth-unsafe -
|
||||||
uni 0.0 < [ uni 1.0 + uni! ] when
|
dup 0.0 < [ 1.0 + ] when
|
||||||
uni lagged-fibonacci [ pt0>> ] [ u>> ] bi set-nth
|
[
|
||||||
|
lagged-fibonacci [ pt0>> ] [ u>> ] bi set-nth-unsafe
|
||||||
lagged-fibonacci [ adjust-ptr ] change-pt0 drop
|
lagged-fibonacci [ adjust-ptr ] change-pt0 drop
|
||||||
lagged-fibonacci [ adjust-ptr ] change-pt1 drop
|
lagged-fibonacci [ adjust-ptr ] change-pt1 drop
|
||||||
uni ; inline
|
] keep ; inline
|
||||||
|
|
||||||
|
: default-lagged-fibonacci ( -- obj )
|
||||||
|
[ random-32 ] with-system-random <lagged-fibonacci> ; inline
|
||||||
|
|
Loading…
Reference in New Issue