hi,
I am new to newlisp and I managed to read and process lines from stdin this way:
	(println (slice (current-line) (div (length (current-line) ) 2)))
)
= print half of each line. A friend needed that.
I would like to do this by calling a function for each line of input but I cannot get it running. I thought of something like this:
    (println ..)
    (read-line)
)
What is wrong with that?
Thanks
   t3o
			
			
			
				Nothing wrong with that.
But map is for transforming a list into a different one based on the function you apply.
You are throwing away the transformed list by just using a print function.
			
			
			
				To get a line of input, you use 
For example, if you wanted to use 
    (map 
       (fn (character)
           (print (char character)))  
       (explode (current-line)))
    (println)
    )
Notice that the anonymous function 'character' (which prints the integer code of a character) is applied to every item in the list of characters produced by 
			
			
				hi and thanks for your answers!
My fault (or one of mine) was to think a call to "read-line" would result in a list of lines that I could process with "map": I wanted to map a shrink function on each of the lines.
Now I know that a call to "read-line" results in only a single line read. Hence its name ;-)
Is the code below the best (shortest; most newlispish) solution for my problem to print only a half of each line of input?
#!/usr/bin/newlisp
(while (read-line)
	(println (slice (current-line) (div (length (current-line) ) 2)))
)
; echo -e "foofoonblablan"| ./echo.lsp
thanks
  t3o
			
			
			
				
(define (half-string str)
  ((div (length str) 2) str))
(while (read-line)
  (println (half-string (current-line))))