diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor index 1539a07d68..333158a0d6 100755 --- a/basis/help/cookbook/cookbook.factor +++ b/basis/help/cookbook/cookbook.factor @@ -182,6 +182,7 @@ $nl ARTICLE: "cookbook-io" "Input and output cookbook" "Ask the user for their age, and print it back:" { $code + "USING: io math.parser ;" ": ask-age ( -- ) \"How old are you?\" print ;" ": read-age ( -- n ) readln string>number ;" ": print-age ( n -- )" @@ -193,22 +194,26 @@ ARTICLE: "cookbook-io" "Input and output cookbook" } "Print the lines of a file in sorted order:" { $code - "utf8 \"lines.txt\" file-lines natural-sort [ print ] each" + "USING: io io.encodings.utf8 io.files sequences sorting ;" + "\"lines.txt\" utf8 file-lines natural-sort [ print ] each" } "Read 1024 bytes from a file:" { $code + "USING: io io.encodings.binary io.files ;" "\"data.bin\" binary [ 1024 read ] with-file-reader" } "Convert a file of 4-byte cells from little to big endian or vice versa, by directly mapping it into memory and operating on it with sequence words:" { $code + "USING: accessors grouping io.files io.mmap kernel sequences ;" "\"mydata.dat\" dup file-info size>> [" " 4 [ reverse-here ] change-each" "] with-mapped-file" } "Send some bytes to a remote host:" { $code - "\"myhost\" 1033 " - "[ { 12 17 102 } >string write ] with-client" + "USING: io io.encodings.ascii io.sockets strings ;" + "\"myhost\" 1033 ascii" + "[ B{ 12 17 102 } write ] with-client" } { $references { }