How to make the cycle in Lisp?

Asked

Viewed 210 times

1

I’m learning lisp at university recently and I’m having some problems adapting to this language.
The cycle let in this language works like a for in java? If yes can show me an example that gives to understand more or less how it works?

1 answer

0

This link contains a large amount of information about this language. Including an explanation of interactions, in section 2.19 you can see how to create a loop which would be equivalent to for java.

Example:

Printing 10 to 20 Numbers.

(loop for a from 10 to 20
    do (print a)
)

The above code is equivalent to the following java code:

for(int i = 10; i <= 20; i++){
    System.out.println(i);
}
  • Responses containing only links are discouraged, because if the link breaks one day, the answer will lose meaning. I suggest putting an example of code here.

  • @Renan, Thanks for the tip. I will edit my reply by putting an example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.