danbaron
09-06-2010, 07:27
[font=courier new][size=8pt]I finally got something to work in Lisp.
In the beginning, some languages are harder than others, yes?
(In the version of Lisp I am trying, Corman Common Lisp (from Roger Corman), all code is compiled.)
("Common" Lisp, is the ANSI standard version of Lisp.)
:oops:
Dan :x :P
;In Common Lisp, anything following a semi-colon is considered to be a comment.
;Make an array of 1000 doubles.
(setf a (make-array 1000 :element-type 'double-float))
;Assign the value, pi, to the first element.
(setf (aref a 0) pi)
;Open a stream (file) for output.
(setq out (open "c:/users/root/desktop/lisp/cz.dat" :direction :output))
;Write "hello" to the output file. "~%", indicates a newline.
(format out "hello~%")
;Write "goodbye" to the output file.
(format out "goodbye~%")
;Format and write the value of the first array element to the output file.
(format out "~16,15,,,,F~%" (aref a 0))
;Close the output file.
(close out)
;The contents of the output file are (without the semi-colons):
;hello
;goodbye
;3.141592653589793
In the beginning, some languages are harder than others, yes?
(In the version of Lisp I am trying, Corman Common Lisp (from Roger Corman), all code is compiled.)
("Common" Lisp, is the ANSI standard version of Lisp.)
:oops:
Dan :x :P
;In Common Lisp, anything following a semi-colon is considered to be a comment.
;Make an array of 1000 doubles.
(setf a (make-array 1000 :element-type 'double-float))
;Assign the value, pi, to the first element.
(setf (aref a 0) pi)
;Open a stream (file) for output.
(setq out (open "c:/users/root/desktop/lisp/cz.dat" :direction :output))
;Write "hello" to the output file. "~%", indicates a newline.
(format out "hello~%")
;Write "goodbye" to the output file.
(format out "goodbye~%")
;Format and write the value of the first array element to the output file.
(format out "~16,15,,,,F~%" (aref a 0))
;Close the output file.
(close out)
;The contents of the output file are (without the semi-colons):
;hello
;goodbye
;3.141592653589793