Create the first clojure project with leiningen 3

Source: Internet
Author: User

Now let's take a look atCode:

The first one is nil, which has the same null value as Java. Like false, nil can express the condition that the condition is not true. The following is an explanation:

 
Nilnil is a possible value of any data type in clojure. nil has the same value as Java null. the clojure conditional System is based around nil and false, with nil and false representing the values of logical falsity in conditional tests-anything else is logical truth. in addition, Nil is used as the end-of-sequence sentinel value in the sequence protocol.

Because the main function code didn't use parameters before, modify the code here to demonstrate how to use parameters:

 
(NS project1.core) (defn-Main "I don't do a whole lot." [& ARGs] (println "Hello, world! ") (Println ARGs) (println (count ARGs )))

Run in repl session:

 
User => (require 'project1. Core) niluser => (project1.core/-Main "B") Hello, world! (B) 1nil

Explanation:

[] Square brackets are used to create a vector (array)

& ARGs refers to variable array elements

(Println ARGs) print all input parameters. ARGs is a list that contains all parameters.

(Count ARGs) calculates the number of parameters

Now let's see how to run without using repl sessionsProgramDirectly enter the following command:

 
~ /Project1 $ lein run-M project1.core "A" Hello, world! ()

The-main function under project1.core namespace is automatically found and executed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.