This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Help translate c+ => lisp!?

6 posts · 2835 views

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!?

Adding in types, the C++ is probably
int x;
cin >> x;
for(int i=0; i<x; i++) { ... }
Here's roughly equivalent CL.
(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!?

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!?

Are we talking Common Lisp or Autolisp (used by AutoCad) or something else?
What program reads the files?

Re: Help translate c+ => lisp!?

The prog. is for Acad! Is there a difference?

Re: Help translate c+ => lisp!?

georg wrote:The prog. is for Acad! Is there a difference?
Well, it is another Lisp dialect, so I presume there is.
Don't take the FUN out of DEFUN !