Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
biu~biu~biu~

帝归 unionx

🦄
biu~biu~biu~
View GitHub Profile
@unionx
unionx / about.md
Created Nov 9, 2011 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
View about.md
@unionx
unionx / about.org
Created Nov 22, 2011
My Programming Language
View about.org

My Programming Language

The language is a lisp dialect.

@unionx
unionx / calc.py
Created Mar 31, 2012
admaster_2012_3_30_count_rectangles
View calc.py
#!/usr/bin/env python
#coding:utf-8
# 题目:下图中一共有多少个矩形?星号表示挖空不计的部分
# # # # # # # # # # #
# # # # # # # # # # #
# # # * * * * # # # #
# # # * * * * # # # #
# # # * * * * # # # #
View c_call_guile.c
#include <stdio.h>
#include <libguile.h>
int main(int argc, char** argv) {
SCM func;
scm_init_guile();
scm_c_primitive_load("c_call_guile.scm");
func = scm_variable_ref(scm_c_lookup("show-me"));
scm_call_0(func);
@unionx
unionx / iter.lisp
Created Jul 21, 2012
Iteration in Common Lisp
View iter.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)
@unionx
unionx / test.el
Created Jul 30, 2012
read and split file in emacs lisp
View test.el
#!/usr/local/bin/emacs --script
(defun read-lines (filename)
(with-temp-buffer
(insert-file-contents filename)
(split-string (buffer-string) "\n" t)))
;; test.log
;; 111111,22222222222,3333333333333
@unionx
unionx / trav.lisp
Created Aug 20, 2012
traverse a list recursively and find specific elements
View trav.lisp
(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))
View root-of-lisp.lisp
(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 Sep 26, 2012
代码最重要的是好看
View count.py
#!/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 Oct 19, 2012
我终于知道tuple这个数据类型有什么用了
View tuple_is_cool.py
#!/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")