Skip to content

Instantly share code, notes, and snippets.

View unionx's full-sized avatar
🦄
biu~biu~biu~

帝归 unionx

🦄
biu~biu~biu~
View GitHub Profile
@unionx
unionx / trav.lisp
Created August 20, 2012 04:45
traverse a list recursively and find specific elements
(defun traverse (lst elt)
(defun traverse-and-count (lst elt cnt)
(if (= 0 (length lst))
cnt
(progn
(if (equal elt (car lst))
(traverse-and-count (cdr lst) elt (+ 1 cnt))
(traverse-and-count (cdr lst) elt cnt)))))
(traverse-and-count lst elt 0))
(defun null. (x)
(eq x '()))
(defun not. (x)
(cond (x '())
('t 't)))
(defun and. (x y)
(cond (x (cond (y 't)
('t '())))
@unionx
unionx / count.py
Created September 26, 2012 15:26
代码最重要的是好看
#!/usr/bin/env python
#coding: utf-8
import os
import sys
# 好吧其实我现在写这种短代码不太考虑怎么写的好了,不过还是有个人习惯在里面
EXTS = ['cc', 'java', 'cpp', 'c', 'py', 'cxx', 'hs', 'lisp', 'scm', 'el', 'clj']
@unionx
unionx / tuple_is_cool.py
Created October 19, 2012 02:57
我终于知道tuple这个数据类型有什么用了
#!/usr/bin/env python
list_in_list = [[1,2,3], [2,2,2], [1,2,3]]
try:
dist_list = list(set(list_in_list))
except TypeError:
print("list in list")
h1 h2 {
font-family: Monaco;
font-style: Normal;
}
h1 {
font-size: 15px;
}
h2 {
@unionx
unionx / development.org
Created November 16, 2012 20:45
Softwares Running on Development Machine

softwares running on my development machine

Jenkins

I use Jenkins as CI server.

@unionx
unionx / reduction1.clj
Created December 3, 2012 22:19
4clojure #60
(fn reduction1
([f col]
(reduction1 f (f (first col)) (rest col)))
([f val col]
(if (empty? col)
(list val)
(cons val (lazy-seq (reduction1 f (f val (first col)) (rest col)))))))
@unionx
unionx / reverse-it.clj
Last active December 19, 2015 05:19
丧心病狂的使用宏的方法
(require '(clojure [string :as string]
[walk :as walk]))
;; page 236 on <Clojure Programming>
(defmacro reverse-it [form]
(walk/postwalk #(if (symbol? %)
(symbol (string/reverse (name %)))
%)
form))
@unionx
unionx / ask.py
Created April 28, 2014 19:52
对比一下CPython和PyPy的速度
#!/usr/bin/env python
import cProfile
def main():
for i in range(100000000):
i / 5.53892138021312312 * 23.23123121321321312
print(i)
cProfile.run("main()")
@unionx
unionx / iter.lisp
Created July 21, 2012 01:07
Iteration in Common Lisp
;;;;;; iteration in common lisp
;;;; do
;; `do` is like `if` in c
(do ((x 1 (+ x 1))
(y 1 (* y 2)))
((> x 5) y) ;; when x is bigger than 5, return y
(print y)