用Leiningen创建第一个Clojure工程三
来源:互联网 发布:php 流媒体播放 编辑:程序博客网 时间:2024/04/29 17:05
现在来看一下前面译文中碰到的代码:
第一个是nil, 和Java的null值相同,和false一样可以表达条件判断不为true的情况。下面是解释:
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.
因为之前main函数代码没有使用参数,这里修改一下代码,演示如何使用参数:
(ns project1.core)(defn -main "I don't do a whole lot." [& args] (println "Hello, World!" ) (println args) (println (count args)))
在REPL会话中运行:
user=> (require 'project1.core)niluser=> (project1.core/-main "b")Hello, World!(b)1nil解释:
[ ] 方括号是指创建一个vector(数组)
& args指的是数组元素可变
(println args) 打印所有输入参数, args是一个list,包含了所有参数
(count args) 计算参数数目
现在看看如何不使用REPL会话运行程序, 直接输入下面的命令:
lein run -m project1.core "a" Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar Hello, World!(a)1会自动找到project1.core namespace下面的-main函数并执行。
- 用Leiningen创建第一个Clojure工程三
- 用Leiningen创建第一个Clojure工程一
- 用Leiningen创建第一个Clojure工程二
- 用Leiningen创建第一个Clojure工程四
- clojure之leiningen生成eclipse工程
- 用Firefly创建第一个工程
- 用Firefly创建第一个工程
- 创建第一个android工程
- 创建第一个Django工程
- 创建第一个Django工程
- 创建第一个Django工程
- django创建第一个工程
- 安装clojure编译工具leiningen
- 安装clojure编译工具leiningen
- 创建第一个Android 3 工程
- 使用uVision 创建第一个工程
- 创建第一个QML工程(学习中)
- eclipse创建第一个Android工程HelloWorld
- 第3章:验证三角形的有效
- android repo 常用命令
- 北京是一个什么地方
- 最好的dwg文件浏览器V12.0(CAD看图软件)下载
- glance命令
- 用Leiningen创建第一个Clojure工程三
- 七周七语言:Prolog Day 3
- 电脑分区知识
- SIFT 资料
- FLEX4 填充方式
- 在任意UIView上显示Badge(兼容IOS6)
- eclipse中使用Jena解析本体文件
- ashx验证注意的地方
- 坚持学习的四条建议