Replace '<file-reader> contents' with 'file-contents' in all vocabs

db4
Aaron Schaefer 2007-12-31 14:47:24 -05:00
parent 2f04bfadbe
commit 897a8ed8aa
13 changed files with 65 additions and 65 deletions

View File

@ -27,4 +27,4 @@ DEFER: crc32-table inline
: crc32 ( seq -- n ) : crc32 ( seq -- n )
>r HEX: ffffffff dup r> [ (crc32) ] each bitxor ; >r HEX: ffffffff dup r> [ (crc32) ] each bitxor ;
: file-crc32 ( path -- n ) <file-reader> contents crc32 ; : file-crc32 ( path -- n ) file-contents crc32 ;

View File

@ -23,11 +23,11 @@ USING: tools.test io.files io threads kernel ;
] unit-test ] unit-test
[ "Hello world.\nHello appender.\n" ] [ [ "Hello world.\nHello appender.\n" ] [
"test-foo.txt" resource-path <file-reader> contents "test-foo.txt" resource-path file-contents
] unit-test ] unit-test
[ "Hello appender.\n" ] [ [ "Hello appender.\n" ] [
"test-bar.txt" resource-path <file-reader> contents "test-bar.txt" resource-path file-contents
] unit-test ] unit-test
[ ] [ "test-foo.txt" resource-path delete-file ] unit-test [ ] [ "test-foo.txt" resource-path delete-file ] unit-test

View File

@ -63,7 +63,7 @@ uses definitions ;
: reset-checksums ( -- ) : reset-checksums ( -- )
source-files get [ source-files get [
swap ?resource-path dup exists? swap ?resource-path dup exists?
[ <file-reader> contents record-checksum ] [ 2drop ] if [ file-contents record-checksum ] [ 2drop ] if
] assoc-each ; ] assoc-each ;
M: pathname where pathname-string 1 2array ; M: pathname where pathname-string 1 2array ;

View File

@ -1,4 +1,4 @@
USING: cryptlib.libcl cryptlib prettyprint kernel alien sequences libc math USING: cryptlib.libcl cryptlib prettyprint kernel alien sequences libc math
tools.test io io.files continuations alien.c-types splitting generic.math ; tools.test io io.files continuations alien.c-types splitting generic.math ;
"=========================================================" print "=========================================================" print
@ -53,12 +53,12 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
! de-envelope ! de-envelope
CRYPT_FORMAT_AUTO [ CRYPT_FORMAT_AUTO [
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [ dup CRYPT_ENVELOPE_RESOURCE = [
envelope-handle CRYPT_ENVINFO_PASSWORD envelope-handle CRYPT_ENVINFO_PASSWORD
"password" set-attribute-string "password" set-attribute-string
] [ ] [
rethrow rethrow
] if ] if
] recover drop ] recover drop
get-bytes-copied . get-bytes-copied .
envelope-handle flush-data envelope-handle flush-data
@ -124,17 +124,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
! de-envelope ! de-envelope
CRYPT_FORMAT_AUTO [ CRYPT_FORMAT_AUTO [
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [ dup CRYPT_ENVELOPE_RESOURCE = [
CRYPT_ALGO_IDEA create-context CRYPT_ALGO_IDEA create-context
context-handle CRYPT_CTXINFO_KEY "0123456789ABCDEF" context-handle CRYPT_CTXINFO_KEY "0123456789ABCDEF"
set-attribute-string set-attribute-string
envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int
set-attribute set-attribute
] [ ] [
rethrow rethrow
] if ] if
] recover drop ] recover drop
get-bytes-copied . get-bytes-copied .
destroy-context destroy-context
envelope-handle flush-data envelope-handle flush-data
@ -151,8 +151,8 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
[ [
! envelope ! envelope
CRYPT_FORMAT_CRYPTLIB [ CRYPT_FORMAT_CRYPTLIB [
"extra/cryptlib/test/large_data.txt" resource-path <file-reader> "extra/cryptlib/test/large_data.txt" resource-path
contents set-pop-buffer file-contents set-pop-buffer
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
get-pop-buffer alien>char-string length 10000 + set-attribute get-pop-buffer alien>char-string length 10000 + set-attribute
envelope-handle CRYPT_ENVINFO_DATASIZE envelope-handle CRYPT_ENVINFO_DATASIZE
@ -175,9 +175,9 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
envelope-handle get-bytes-copied pop-data envelope-handle get-bytes-copied pop-data
get-bytes-copied . get-bytes-copied .
! pop-buffer-string . ! pop-buffer-string .
[ "/opt/local/lib/libcl.dylib(dylib1.o):" ] [ "/opt/local/lib/libcl.dylib(dylib1.o):" ]
[ pop-buffer-string "\n" split first ] unit-test [ pop-buffer-string "\n" split first ] unit-test
[ "00000000 t __mh_dylib_header" ] [ "00000000 t __mh_dylib_header" ]
[ pop-buffer-string "\n" split last/first first ] unit-test [ pop-buffer-string "\n" split last/first first ] unit-test
] with-envelope ] with-envelope
] with-cryptlib ] with-cryptlib
@ -192,7 +192,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
CRYPT_FORMAT_CRYPTLIB [ CRYPT_FORMAT_CRYPTLIB [
envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string
"extra/cryptlib/test/large_data.txt" resource-path "extra/cryptlib/test/large_data.txt" resource-path
<file-reader> contents set-pop-buffer file-contents set-pop-buffer
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
get-pop-buffer alien>char-string length 10000 + set-attribute get-pop-buffer alien>char-string length 10000 + set-attribute
envelope-handle CRYPT_ENVINFO_DATASIZE envelope-handle CRYPT_ENVINFO_DATASIZE
@ -204,17 +204,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
get-bytes-copied . get-bytes-copied .
pop-buffer-string . pop-buffer-string .
] with-envelope ] with-envelope
! de-envelope ! de-envelope
CRYPT_FORMAT_AUTO [ CRYPT_FORMAT_AUTO [
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE 130000 set-attribute envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE 130000 set-attribute
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [ [ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [ dup CRYPT_ENVELOPE_RESOURCE = [
envelope-handle CRYPT_ENVINFO_PASSWORD envelope-handle CRYPT_ENVINFO_PASSWORD
"password" set-attribute-string "password" set-attribute-string
] [ ] [
rethrow rethrow
] if ] if
] recover drop ] recover drop
get-bytes-copied . get-bytes-copied .
@ -226,7 +226,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
[ "/opt/local/lib/libcl.dylib(dylib1.o):" ] [ "/opt/local/lib/libcl.dylib(dylib1.o):" ]
[ pop-buffer-string "\n" split first ] unit-test [ pop-buffer-string "\n" split first ] unit-test
[ "00000000 t __mh_dylib_header" ] [ "00000000 t __mh_dylib_header" ]
[ pop-buffer-string "\n" split last/first first ] unit-test [ pop-buffer-string "\n" split last/first first ] unit-test
] with-envelope ] with-envelope
] with-cryptlib ] with-cryptlib
@ -274,7 +274,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
check-certificate check-certificate
add-public-key add-public-key
f 0 CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate f 0 CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate
get-cert-length *int dup malloc swap get-cert-length *int dup malloc swap
CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate CRYPT_CERTFORMAT_TEXT_CERTIFICATE export-certificate
get-cert-buffer alien>char-string print get-cert-buffer alien>char-string print
] with-certificate ] with-certificate
@ -295,15 +295,15 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
! ... ! ...
! <at> localhost's password: (any password will be accepted) ! <at> localhost's password: (any password will be accepted)
! If you want to run the test again you should clean the [localhost]:3000 ! If you want to run the test again you should clean the [localhost]:3000
! ssh-rsa entry in the known_hosts file, in your home directory under the .ssh ! ssh-rsa entry in the known_hosts file, in your home directory under the .ssh
! folder, since the test generates a new RSA certificate on every run. ! folder, since the test generates a new RSA certificate on every run.
[ [
CRYPT_KEYSET_FILE "extra/cryptlib/test/keys.p15" resource-path CRYPT_KEYSET_FILE "extra/cryptlib/test/keys.p15" resource-path
CRYPT_KEYOPT_READONLY [ CRYPT_KEYOPT_READONLY [
CRYPT_KEYID_NAME "private key" "password" get-private-key CRYPT_KEYID_NAME "private key" "password" get-private-key
CRYPT_SESSION_SSH_SERVER [ CRYPT_SESSION_SSH_SERVER [
session-handle CRYPT_SESSINFO_SERVER_NAME "localhost" session-handle CRYPT_SESSINFO_SERVER_NAME "localhost"
@ -312,7 +312,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
session-handle CRYPT_SESSINFO_SERVER_PORT 3000 set-attribute session-handle CRYPT_SESSINFO_SERVER_PORT 3000 set-attribute
session-handle CRYPT_SESSINFO_PRIVATEKEY session-handle CRYPT_SESSINFO_PRIVATEKEY
context-handle *int set-attribute context-handle *int set-attribute
[ session-handle CRYPT_SESSINFO_ACTIVE 1 set-attribute ] [ [ session-handle CRYPT_SESSINFO_ACTIVE 1 set-attribute ] [
@ -328,9 +328,9 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
length push-data length push-data
session-handle flush-data session-handle flush-data
] [ ] [
rethrow rethrow
] if ] if
] recover drop ] recover drop
] with-session ] with-session
] with-keyset ] with-keyset

View File

@ -81,11 +81,11 @@ IN: html.parser.analyzer
! ] if ; ! ] if ;
! clear "/Users/erg/web/fark.html" <file-reader> contents parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map ! clear "/Users/erg/web/fark.html" file-contents parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map
! clear "http://fark.com" http-get parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map ! clear "http://fark.com" http-get parse-html find-links [ "go.pl" swap start ] subset [ "=" split peek ] map
! clear "/Users/erg/web/hostels.html" <file-reader> contents parse-html "Currency" "name" pick find-first-attribute-key-value ! clear "/Users/erg/web/hostels.html" file-contents parse-html "Currency" "name" pick find-first-attribute-key-value
! clear "/Users/erg/web/hostels.html" <file-reader> contents parse-html ! clear "/Users/erg/web/hostels.html" file-contents parse-html
! "Currency" "name" pick find-first-attribute-key-value ! "Currency" "name" pick find-first-attribute-key-value
! pick find-between remove-blank-text ! pick find-between remove-blank-text

View File

@ -1,18 +1,14 @@
USING: io io.files io.streams.string http.server.templating USING: io io.files io.streams.string http.server.templating kernel tools.test
kernel tools.test sequences ; sequences ;
IN: temporary IN: temporary
: test-template ( path -- ? ) : test-template ( path -- ? )
"extra/http/server/templating/test/" swap append "extra/http/server/templating/test/" swap append
[ [
".fhtml" append resource-path ".fhtml" append resource-path
[ run-template-file ] string-out [ run-template-file ] string-out
] keep ] keep
".html" append resource-path file-contents = ;
".html" append resource-path
<file-reader> contents
= ;
[ t ] [ "example" test-template ] unit-test [ t ] [ "example" test-template ] unit-test
[ t ] [ "bug" test-template ] unit-test [ t ] [ "bug" test-template ] unit-test

View File

@ -82,7 +82,7 @@ DEFER: <% delimiter
templating-vocab use+ templating-vocab use+
dup source-file file set ! so that reload works properly dup source-file file set ! so that reload works properly
[ [
?resource-path <file-reader> contents ?resource-path file-contents
[ eval-template ] [ html-error. drop ] recover [ eval-template ] [ html-error. drop ] recover
] keep ] keep
] with-scope ] with-scope

View File

@ -1,9 +1,7 @@
! Copyright (C) 2007 Gavin Harrison ! Copyright (C) 2007 Gavin Harrison
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel math sequences kernel.private namespaces arrays io io.files
USING: kernel math sequences kernel.private namespaces arrays splitting io.binary math.functions vectors quotations combinators.private ;
io io.files splitting io.binary math.functions vectors
quotations combinators.private ;
IN: icfp.2006 IN: icfp.2006
SYMBOL: regs SYMBOL: regs
@ -58,7 +56,7 @@ SYMBOL: open-arrays
>r get-cba r> >r get-cba r>
swap >r >r [ reg-val ] 2apply swap r> call r> swap >r >r [ reg-val ] 2apply swap r> call r>
set-reg f ; inline set-reg f ; inline
: op1 ( opcode -- ? ) : op1 ( opcode -- ? )
[ swap arr-val ] binary-op ; [ swap arr-val ] binary-op ;
@ -89,7 +87,7 @@ SYMBOL: open-arrays
: op8 ( opcode -- ? ) : op8 ( opcode -- ? )
?grow-storage ?grow-storage
get-cb >r reg-val open-arrays get pop [ new-array ] keep r> get-cb >r reg-val open-arrays get pop [ new-array ] keep r>
set-reg f ; set-reg f ;
: op9 ( opcode -- ? ) : op9 ( opcode -- ? )
@ -111,7 +109,7 @@ SYMBOL: open-arrays
: op13 ( opcode -- ? ) : op13 ( opcode -- ? )
[ get-value ] keep get-special set-reg f ; [ get-value ] keep get-special set-reg f ;
: advance ( -- val opcode ) : advance ( -- val opcode )
finger get arrays get first nth finger get arrays get first nth
finger inc dup get-op ; finger inc dup get-op ;
@ -129,7 +127,7 @@ SYMBOL: open-arrays
[ run-op exec-loop ] unless ; [ run-op exec-loop ] unless ;
: load-platters ( path -- ) : load-platters ( path -- )
<file-reader> contents 4 group [ be> ] map file-contents 4 group [ be> ] map
0 arrays get set-nth ; 0 arrays get set-nth ;
: init ( path -- ) : init ( path -- )

View File

@ -1,11 +1,9 @@
USING: io io.mmap io.files kernel tools.test continuations USING: io io.mmap io.files kernel tools.test continuations sequences ;
sequences ;
IN: temporary IN: temporary
[ "mmap-test-file.txt" resource-path delete-file ] catch drop [ "mmap-test-file.txt" resource-path delete-file ] catch drop
[ ] [ "mmap-test-file.txt" resource-path <file-writer> [ "12345" write ] with-stream ] unit-test [ ] [ "mmap-test-file.txt" resource-path <file-writer> [ "12345" write ] with-stream ] unit-test
[ ] [ "mmap-test-file.txt" resource-path dup file-length [ CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test [ ] [ "mmap-test-file.txt" resource-path dup file-length [ CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
[ 5 ] [ "mmap-test-file.txt" resource-path dup file-length [ length ] with-mapped-file ] unit-test [ 5 ] [ "mmap-test-file.txt" resource-path dup file-length [ length ] with-mapped-file ] unit-test
[ "22345" ] [ "mmap-test-file.txt" resource-path <file-reader> contents ] unit-test [ "22345" ] [ "mmap-test-file.txt" resource-path file-contents ] unit-test
[ "mmap-test-file.txt" resource-path delete-file ] catch drop [ "mmap-test-file.txt" resource-path delete-file ] catch drop

View File

@ -38,7 +38,7 @@ IN: project-euler.022
] "" make ; ] "" make ;
: source-022 ( -- seq ) : source-022 ( -- seq )
(source-022) <file-reader> contents [ quotable? ] subset "," split ; (source-022) file-contents [ quotable? ] subset "," split ;
: alpha-value ( str -- n ) : alpha-value ( str -- n )
string>digits [ 9 - ] sigma ; string>digits [ 9 - ] sigma ;

View File

@ -38,12 +38,12 @@ IN: project-euler.067
<PRIVATE <PRIVATE
: pyramid ( -- seq ) : pyramid ( -- seq )
"resource:extra/project-euler/067/triangle.txt" ?resource-path <file-reader> "resource:extra/project-euler/067/triangle.txt" ?resource-path
lines [ " " split [ string>number ] map ] map ; <file-reader> lines [ " " split [ string>number ] map ] map ;
PRIVATE> PRIVATE>
: euler067 ( -- best ) : euler067 ( -- answer )
pyramid propagate-all first first ; pyramid propagate-all first first ;
! [ euler067 ] 100 ave-time ! [ euler067 ] 100 ave-time

View File

@ -74,6 +74,15 @@ PRIVATE>
: sum-proper-divisors ( n -- sum ) : sum-proper-divisors ( n -- sum )
dup sum-divisors swap - ; dup sum-divisors swap - ;
: abundant? ( n -- ? )
dup sum-proper-divisors < ;
: deficient? ( n -- ? )
dup sum-proper-divisors > ;
: perfect? ( n -- ? )
dup sum-proper-divisors = ;
! The divisor function, counts the number of divisors ! The divisor function, counts the number of divisors
: tau ( n -- n ) : tau ( n -- n )
prime-factorization* flip second 1 [ 1+ * ] reduce ; prime-factorization* flip second 1 [ 1+ * ] reduce ;

View File

@ -1,6 +1,5 @@
USING: xmode.tokens xmode.marker USING: xmode.tokens xmode.marker xmode.catalog kernel html html.elements io
xmode.catalog kernel html html.elements io io.files io.files sequences words ;
sequences words ;
IN: xmode.code2html IN: xmode.code2html
: htmlize-tokens ( tokens -- ) : htmlize-tokens ( tokens -- )
@ -21,7 +20,7 @@ IN: xmode.code2html
: default-stylesheet ( -- ) : default-stylesheet ( -- )
<style> <style>
"extra/xmode/code2html/stylesheet.css" "extra/xmode/code2html/stylesheet.css"
resource-path <file-reader> contents write resource-path file-contents write
</style> ; </style> ;
: htmlize-stream ( path stream -- ) : htmlize-stream ( path stream -- )