Skip to content

Instantly share code, notes, and snippets.

View xieyuheng's full-sized avatar

谢宇恒 / Xie Yuheng xieyuheng

View GitHub Profile
@xieyuheng
xieyuheng / cat.lisp
Created January 22, 2015 03:30
a cute CAT ^-^ in common lisp
(defmacro cat
((&key (to nil)
(trim '())
prefix
postfix)
&body form#list-of-list)
(let* ((form#list-of-list#2
(apply (function append)
(mapcar (lambda (list)
(list prefix
@xieyuheng
xieyuheng / mix-fix.cicada
Last active August 29, 2015 14:15
mix-fix notation ^-^
===================================
with the following principle
1 2 (add) = 1 (add 2) = (add 1 2)
all the following code blocks eval to the same result
i.e. function called "fun" applys to arguments 1 2 3
-----------------------------------
2 1 (sub)
@xieyuheng
xieyuheng / offset.c
Created May 1, 2015 05:47
to get offset of structure for assembly code
#include <sys/types.h>
#include <sys/stat.h>
#include <stddef.h>
#include <time.h>
// the following are reported by : man 2 stat
struct the_stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
(define hash-table-preparation-interface
(interface ()
hash-table:get-size
in-cicada-key->key
create-in-cicada-key
key->finite-sum
key-equal?
hash))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(regexp-match-positions
(regexp
(cat
((object-name (regexp "needle")))
(" ")
((object-name (regexp "needle")))))
"hay needle needle stack")
(define-syntax cat
(syntax-rules ()
[(cat (str . args))
(format str . args)]
[(cat (str . args) (str2 . args2) ...)
(string-append
(cat (str . args))
(cat (str2 . args2) ...))]))
(define-syntax orz
(letrec ([f (lambda (x) (cons 'a x))]
[g (lambda (x) (cons 'b (f x)))]
[h (lambda (x) (g (cons 'c x)))])
(cons 'd (h '())))
;; (d b a c)
(letrec ([f (lambda (x k) (k (cons 'a x)))]
[g (lambda (x k) (f x (lambda (v) (k (cons 'b v)))))]
[h (lambda (x k) (g (cons 'c x) k))])
(h '() (lambda (v) (cons 'd v))))
@xieyuheng
xieyuheng / fun.rkt
Last active November 21, 2015 22:33
(require (for-syntax syntax/parse))
(define-syntax fun
(lambda (stx)
(syntax-parse stx
#:literals (->)
[(fun [v ... -> r ...] ...)
(syntax
(match-lambda** [(v ...) (begin r ...)] ...))])))
* 一羣屎殼郎定理
- 保守力定理
不動點定理
一羣屎殼郎定理
- 假設一
每個人在解決問題時
都會使用自己所能想到的最優解法
命令行中文補全
假設當前路徑下有且僅有 '小學' '數書' '書法' 三個子路徑
當我在命令行裏有如下輸入 ('|' 代表光標的位置)
cd x|
此時按 <tab> 將爲我做如下補全
cd 小學/|
當有