Lisp Programming Hello-World Example on GNU/Linux

August 11, 2019 | By the+gnu+linux+evangelist | Filed in: Tutorial.

Hello World

  1. 3. Making Hello World

    Create an Common LISP Hello World
    First, I make a directory to keep things well ordered:

    mkdir ~/Documents/cLisp

    Next Change to the Target cLisp directory with:

    cd ~/Documents/cLisp

    Now Edit the Hello World file:

    nano helloworld.lisp

    Here for simplicity I’ll make use of the nano editor…
    So Append this Common LISP content:

    (defun hello-world ()
      (format t "Hello, world!"))
    

    Ctrl+x to Save & Exit from nano editor :)

  2. 4. Running Hello World

    To Execute the Common LISP Hello World
    First, give Execution Permissions to example:

    chmod +x helloworld.lisp

    Then Launch the Lisp Cli Interpreter with:

    clisp

     - Terminal CLisp Intepreter
    Finally, Load and Run the example:

    1> load("helloworld.lisp")
    ;; Loading file helloworld.lisp ...
    ;; Loaded file helloworld.lisp
    T
    

    Then to Run the Common LISP hello-world Function:

    2> (hello-world)
    Hello world!
    NIL
    

    In the end to Quit the Common LISP shell hits Ctrl+z.

Contents


Tags: , , , ,

QuickChic Theme • Powered by WordPress