Hi,
I am a newcomer can anywhere translate this to lisp?
cin<<x;
for( i = 0; i < x; i++) {
…
}
Thx..
Georg#
I am a newcomer can anywhere translate this to lisp?
cin<<x;
for( i = 0; i < x; i++) {
…
}
Thx..
Georg#
Discuss and learn Lisp programming of all dialects
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.
6 posts · 2835 views
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.georg wrote:The prog. is for Acad! Is there a difference?Well, it is another Lisp dialect, so I presume there is.