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 )
>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
[ "Hello world.\nHello appender.\n" ] [
"test-foo.txt" resource-path <file-reader> contents
"test-foo.txt" resource-path file-contents
] unit-test
[ "Hello appender.\n" ] [
"test-bar.txt" resource-path <file-reader> contents
"test-bar.txt" resource-path file-contents
] unit-test
[ ] [ "test-foo.txt" resource-path delete-file ] unit-test

View File

@ -63,7 +63,7 @@ uses definitions ;
: reset-checksums ( -- )
source-files get [
swap ?resource-path dup exists?
[ <file-reader> contents record-checksum ] [ 2drop ] if
[ file-contents record-checksum ] [ 2drop ] if
] assoc-each ;
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 ;
"=========================================================" print
@ -53,12 +53,12 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
! de-envelope
CRYPT_FORMAT_AUTO [
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [
dup CRYPT_ENVELOPE_RESOURCE = [
envelope-handle CRYPT_ENVINFO_PASSWORD
"password" set-attribute-string
] [
"password" set-attribute-string
] [
rethrow
] if
] if
] recover drop
get-bytes-copied .
envelope-handle flush-data
@ -124,17 +124,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
! de-envelope
CRYPT_FORMAT_AUTO [
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [
dup CRYPT_ENVELOPE_RESOURCE = [
CRYPT_ALGO_IDEA create-context
context-handle CRYPT_CTXINFO_KEY "0123456789ABCDEF"
set-attribute-string
envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int
envelope-handle CRYPT_ENVINFO_SESSIONKEY context-handle *int
set-attribute
] [
rethrow
] if
] [
rethrow
] if
] recover drop
get-bytes-copied .
destroy-context
envelope-handle flush-data
@ -151,8 +151,8 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
[
! envelope
CRYPT_FORMAT_CRYPTLIB [
"extra/cryptlib/test/large_data.txt" resource-path <file-reader>
contents set-pop-buffer
"extra/cryptlib/test/large_data.txt" resource-path
file-contents set-pop-buffer
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
get-pop-buffer alien>char-string length 10000 + set-attribute
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
get-bytes-copied .
! 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
[ "00000000 t __mh_dylib_header" ]
[ "00000000 t __mh_dylib_header" ]
[ pop-buffer-string "\n" split last/first first ] unit-test
] with-envelope
] with-cryptlib
@ -192,7 +192,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
CRYPT_FORMAT_CRYPTLIB [
envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string
"extra/cryptlib/test/large_data.txt" resource-path
<file-reader> contents set-pop-buffer
file-contents set-pop-buffer
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
get-pop-buffer alien>char-string length 10000 + set-attribute
envelope-handle CRYPT_ENVINFO_DATASIZE
@ -204,17 +204,17 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
get-bytes-copied .
pop-buffer-string .
] with-envelope
! de-envelope
CRYPT_FORMAT_AUTO [
envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE 130000 set-attribute
[ envelope-handle get-pop-buffer get-bytes-copied push-data ] [
dup CRYPT_ENVELOPE_RESOURCE = [
dup CRYPT_ENVELOPE_RESOURCE = [
envelope-handle CRYPT_ENVINFO_PASSWORD
"password" set-attribute-string
] [
rethrow
] if
] [
rethrow
] if
] recover drop
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):" ]
[ 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
] with-envelope
] with-cryptlib
@ -274,7 +274,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
check-certificate
add-public-key
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
get-cert-buffer alien>char-string print
] 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)
! 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
! 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
! folder, since the test generates a new RSA certificate on every run.
[
CRYPT_KEYSET_FILE "extra/cryptlib/test/keys.p15" resource-path
CRYPT_KEYOPT_READONLY [
CRYPT_KEYID_NAME "private key" "password" get-private-key
CRYPT_SESSION_SSH_SERVER [
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_PRIVATEKEY
context-handle *int 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
session-handle flush-data
] [
rethrow
] if
] [
rethrow
] if
] recover drop
] with-session
] with-keyset

View File

@ -81,11 +81,11 @@ IN: html.parser.analyzer
! ] 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 "/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
! pick find-between remove-blank-text

View File

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

View File

@ -82,7 +82,7 @@ DEFER: <% delimiter
templating-vocab use+
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
] keep
] with-scope

View File

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

View File

@ -1,11 +1,9 @@
USING: io io.mmap io.files kernel tools.test continuations
sequences ;
USING: io io.mmap io.files kernel tools.test continuations sequences ;
IN: temporary
[ "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 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
[ "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

View File

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

View File

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

View File

@ -74,6 +74,15 @@ PRIVATE>
: sum-proper-divisors ( n -- sum )
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
: tau ( n -- n )
prime-factorization* flip second 1 [ 1+ * ] reduce ;

View File

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