Page 1 of 1
Help translate c+ => lisp!?
Posted: Fri Nov 11, 2011 10:52 am
by georg
Hi,
I am a newcomer can anywhere translate this to lisp?
cin<<x;
for( i = 0; i < x; i++) {
…
}
Thx..
Georg#
Re: Help translate c+ => lisp!?
Posted: Fri Nov 11, 2011 8:43 pm
by nuntius
Adding in types, the C++ is probably
Code: Select all
int x;
cin >> x;
for(int i=0; i<x; i++) { ... }
Here's roughly equivalent CL.
Code: Select all
(let ((x (read *standard-input*)))
(assert (integerp x))
(dotimes (i x) ...))
There a few options for checking that x is an integer (such as an IF instead of the assert), there are times to prefer DO or LOOP over DOTIMES, and *STANDARD-INPUT* is a default and doesn't need to be specified to READ.
Please check out some of the books in the FAQ for this forum.
Re: Help translate c+ => lisp!?
Posted: Sat Nov 12, 2011 2:05 am
by georg
Thx for you reply!
still I have a problem whit the ACAD lisp
me lisp doesn't not work...
(print)
(defun C:PL ()
(setvar "OSMODE" 1)
(INITGET 1)
(setq P1 (getpoint "\n Lower Left Endpoint: "))
(INITGET 1)
(setq P2 (getpoint "\n Upper Right Endpoint: "))
(setvar "OSMODE" 0)
;;***********************************************
(print "How many copies?")
(let ((x (read *standard-input*)))
(assert (integerp x))
(dotimes (i x)
;************************************************* **************************************************
(setvar "cmdecho" 0)
(command "-PLOT" "j" "" "Canon MP270 series Printer" "A4" "" "" "" "fe" P1 P2 "" "" "" "acad.ctb" "" "" "" "" "" "" "")
))
;************************************************* **************************************************
)
Re: Help translate c+ => lisp!?
Posted: Sat Nov 12, 2011 11:07 am
by nuntius
Are we talking Common Lisp or Autolisp (used by AutoCad) or something else?
What program reads the files?
Re: Help translate c+ => lisp!?
Posted: Sat Nov 12, 2011 12:08 pm
by georg
The prog. is for Acad! Is there a difference?
Re: Help translate c+ => lisp!?
Posted: Sun Nov 13, 2011 1:21 am
by Indecipherable
georg wrote:The prog. is for Acad! Is there a difference?
Well, it is another Lisp dialect, so I presume there is.