Search code examples
newlisp

Read stdin to string in Newlisp


How do you read the entire contents of standard input into a string in Newlisp? (i.e the entire remaining contents after the current read position - this operation is commonly called "slurp file")


Solution

  • You can use this:

    (define (read-all)
      (let (r "" ch "")
          (while (setf ch (read-char))
            (setf r (append r (char ch))))
        r))
    

    See also: http://www.newlisp.org/downloads/newlisp_manual.html#read-char