logo image

CommonLisp Hello World! 

CommonLisp Hello World! 

   
   

Output:

Click on RUN button to see the output

Common Lisp online compiler

Write, Run & Share Common Lisp code online using OneCompiler's Common Lisp online compiler for free. It's one of the robust, feature-rich online compilers for Common Lisp language, running the latest Common Lisp version 5.3. Getting started with the OneCompiler's Common Lisp editor is easy and fast. The editor shows sample boilerplate code when you choose language as Common Lisp. OneCompiler also has reference programs, where you can look for the sample code and start learning. Happy learning!!

Read inputs from stdin

OneCompiler's Common Lisp online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Common Lisp program which takes name as input and prints hello message with your name.

(setq name (read))
(princ "Hello ")
(write name)

About Common Lisp

Common Lisp is a generic language suitable for a wide range of industry applications. It is often referred as Programmable programming language because of it's high extensibility, machine independence, extensive control structures, dynamic updation of programs etc.

Common LISP was invented by John McCarthy in 1958 and was first implemenyted by Steve Russell on an IBM 704 computer.

Syntax help

Variables

  • Global variables are declared using defvar keyword and these variables will be in effect until a new value is assigned.
  • Type declaration is not required in LISP

Example

(defvar x 10)
(write x)
  • Local variables are declared with in a function or a procedure. The scope of local variables will be only in that function.
  • let and progare used to declare local variables.

Syntax

(let ((var1  value1) (var2  value2).. (varn  valuen))<expressions>)
  • You can also create global and local variables using setq

Example

(setq a 10)

Loops

1. Loop:

This is the simplest looping mechanism in LISP. This allows the execute the set of statements repeatedly until a return statement is encountered.

Syntax

(loop (s-expressions))

2. For:

For loop is used to iterate a set of statements based on a condition.

(loop for loop-variable in <a list>
   do (action)
)

3. Do:

Do is also used to iterate a set of statements and then check the condition

(do ((var1    val1   updated-val1)
      (var2   val2   updated-val2)
      (var3   val3   updated-val3)
   ...)
   (test return-value)
   (s-expressions)
)

4. Dotimes:

Dotimes is used to iterate for fixed number of iterations.

Syntax:

(dotimes (n val)
  statements

Help us with your feedback!

Reference Programs:

CommonLisp

No tags available for CommonLisp

How to use?

Choose the language in which you want to run your program, by clicking the button next to Run. And then write your code in the code box, You can use the auto complete snippets and warnings and errors which helps you to write better code faster way.
Once you are done writing your code click the Run button, now the code will be submitted to OneCompiler and you will see the results in a second.

How to contribute?

Please fork OneCompiler repository and contribute us by adding more languages or the features to the existing OneCompiler backend.
You can also contibute to the community by adding more programs which users can search and use as base code for their programs.

API & More

You can embed OneCompiler into your own website. That helps your website users to write and test their programs within your website.
If you want to run and see the results from your backend you can utilize the OneCompiler API by integrating it with your backend.