-
github上你可以用别人的现成的代码 直接 git clone 即可了
-
然后你也想改代码或者贡献代码咋办?
大名鼎鼎的 Paul Graham 写过一篇《The Roots of Lisp》,讲解他对 Lisp 根源的理解。这篇文章我在很多年前就试图阅读,但是都不大能读懂,直到去年年末时候我读了几十年前的 Lisp 1.5 手册的相关部分,终于算是理解了。再读一遍 pg 的文章,也就完全能懂了。现在结合自己的理解尝试把这些概念重述一遍。这篇文章就是想以自己的话语阐述一遍这些基本概念。这里会偏重于数学式的思维训练而不是实用性的程序编写,所以和实际情况会稍有出入。计划写两部分,第一部分是7个原始操作,第二部分讲实现 Lisp 解释器。
在 lisp manual 里面,我看到 John 使用了一种数学人很喜欢的表述方式,就是先定义符号和规则,然后在这套规则下让我们来看看我们可以怎么玩。有一点数学基础的人可能就会觉得这样理解会很容易。
##基本定义
首先定义符号
,为了简化,我在这篇文章里就定义可用的符号
为 26 个小写字母、10个数字、空格、左右圆括号和单引号。
然后我们定义原子(atom)
,原子就是由字母和数字组成序列并且只能由字母开头,比如 abc123,比如 foo 或 bar 都是原子。
; A REPL-based, annotated Seesaw tutorial | |
; Please visit https://github.com/daveray/seesaw for more info | |
; | |
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers | |
; Seesaw's basic features and philosophy, but only scratches the surface | |
; of what's available. It only assumes knowledge of Clojure. No Swing or | |
; Java experience is needed. | |
; | |
; This material was first presented in a talk at @CraftsmanGuild in | |
; Ann Arbor, MI. |
<div class="container"> | |
<div class="row"> | |
<div class="col-sm-6 col-md-4 col-md-offset-4"> | |
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1> | |
<div class="account-wall"> | |
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120" | |
alt=""> | |
<form class="form-signin"> | |
<input type="text" class="form-control" placeholder="Email" required autofocus> | |
<input type="password" class="form-control" placeholder="Password" required> |
val rnd = Math.random() | |
val n = Math.abs(rnd) | |
assert(n > 0) |
/** | |
* <b>Fixed Point Combinator is:</b> | |
* Y = λf.(λx.f (x x)) (λx.f (x x)) | |
* | |
* <b>Proof of correctness:</b> | |
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
* = g (Y g) (by second equality) [1] |
object Solution { | |
def main(args: Array[String]) { | |
val sc = new java.util.Scanner(System.in); | |
var n = sc.nextInt(); | |
var arr = new Array[Int](n); | |
for (arr_i <- 0 to n - 1) { | |
arr(arr_i) = sc.nextInt(); | |
} | |
println(arr.map(_.toLong).sum) |
object Solution { | |
def main(args: Array[String]) { | |
val sc = new java.util.Scanner(System.in); | |
var n = sc.nextInt(); | |
var a = Array.ofDim[Int](n, n); | |
for (a_i <- 0 to n - 1) { | |
for (a_j <- 0 to n - 1) { | |
a(a_i)(a_j) = sc.nextInt(); | |
} |
object Solution { | |
def main(args: Array[String]) { | |
val sc = new java.util.Scanner (System.in); | |
var n = sc.nextInt(); | |
var arr = new Array[Int](n); | |
for(arr_i <- 0 to n-1) { | |
arr(arr_i) = sc.nextInt(); | |
} | |
This is an adaptation of https://twitter.com/jasonneylon script.
In the terminal window, you can open your current repo (at the current branch) in your default browser.
My adaptation was adding options to view the commits, branches, pull requests or issues for the repo using one of the additional options (added support for wiki, settings, pulse, graphs, network):
[h] => View help
[c] => View commits
[c {SHA}] => View specific commit from commit SHA
[b] => View branches