diff --git a/collects/2htdp/batch-io.rkt b/collects/2htdp/batch-io.rkt index dd81e852b0..f0d8e900d4 100644 --- a/collects/2htdp/batch-io.rkt +++ b/collects/2htdp/batch-io.rkt @@ -53,18 +53,20 @@ ;; -- f must be formated as a a file with comma-separated values (Any) ;; read the specified file as a list of lists---one per line---of values (Any) - read-csv-file/rows ;; String ([Listof Any] -> X) -> [Listof X] - ;; -- f must be formated as a a file with comma-separated values (Any) - ;; read the specified file as a file of comma-separated values, apply the second - ;; argument to each row, i.e., list of CSV on one line - write-file ;; String String -> String ;; (write-file filename str) writes str to filename; ;; produces the file name as a confirmation that the write succeeded ;; *input-devives*: symbols that redirect input from an input-port ;; *output-devives*: symbols that redirect output from a output-port - ) + ) + +(provide-higher-order-primitive + read-csv-file/rows (_ row-processor) ;; String ([Listof Any] -> X) -> [Listof X] + ;; -- f must be formated as a a file with comma-separated values (Any) + ;; read the specified file as a file of comma-separated values, apply the second + ;; argument to each row, i.e., list of CSV on one line + ) ;; ----------------------------------------------------------------------------- diff --git a/collects/2htdp/tests/batch-io-csv-ho.rkt b/collects/2htdp/tests/batch-io-csv-ho.rkt new file mode 100644 index 0000000000..e532bb0d2b --- /dev/null +++ b/collects/2htdp/tests/batch-io-csv-ho.rkt @@ -0,0 +1,6 @@ +;; The first three lines of this file were inserted by DrRacket. They record metadata +;; about the language level of this file in a form that our tools can easily process. +#reader(lib "htdp-beginner-reader.ss" "lang")((modname read-with-csv-ho) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) +(require 2htdp/batch-io) + +(check-expect (read-csv-file/rows "batch-io-csv-ho.rktl" length) (cons 3 empty)) diff --git a/collects/2htdp/tests/batch-io-csv-ho.rktl b/collects/2htdp/tests/batch-io-csv-ho.rktl new file mode 100644 index 0000000000..b2ffb02521 --- /dev/null +++ b/collects/2htdp/tests/batch-io-csv-ho.rktl @@ -0,0 +1 @@ +a,b,c diff --git a/collects/2htdp/xtest b/collects/2htdp/xtest index 5a80aef74e..3d157b4194 100755 --- a/collects/2htdp/xtest +++ b/collects/2htdp/xtest @@ -17,6 +17,7 @@ run error-in-draw.rkt run -t batch-io.rkt run -t batch-io2.rkt run -t batch-io3.rkt +run -t batch-io-csv-ho.rkt run clause-once.rkt run full-scene-visible.rkt run image-too-large.rkt