This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
long x[]={1, 3,6,8,0,0,0,0, 32,32, | |
4,32, 1022,32,1020,36 ,32,1022, 34,508,32 , | |
32,509,34 , 508,32,36, 32,0,32,36,1022,508,80, | |
1023, 32,260 ,136, | |
32, 32 , 508 , 260,32 , 32, | |
0404, 514, 32,32 ,0,0,0 ,0x0, | |
994 , 0466, 0772, 47,548,950, 168, 296, 559, | |
694,69 ,174, 0x228, 0x3B6 , 01646,0141,01744, | |
01266 ,0124 ,2033 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
until [ -z $1 ]; do | |
unix2dos $1 2>/dev/null | |
iconv -f UTF-8 -t GBK $1 -o /tmp/unix2doc.tmp 2>/dev/null | |
if [ $? -eq 0 ]; then | |
mv /tmp/unix2doc.tmp $1 | |
echo "linux2win: converting file $1 to WIN format ..." | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* a clever way to implement string multiplication in JavaScript */ | |
String.prototype.times = function(n) { | |
return Array.prototype.join.call({length:n+1}, this); | |
}; | |
"js".times(5) // => "jsjsjsjsjs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'strscan' | |
lex = [/"[^\\"]*(?:\\.[^\\"]*)*"/, # string | |
/'[^\\']*(?:\\.[^\\']*)*'/, # char | |
/\/\*.*?\*\//m, # multi-line | |
/\/\/(?:.*?\\(?:\r?\n|\r))*.*/, # single-line | |
/.|\s+/] # rest | |
ARGV.each do |source| | |
stream = StringScanner.new File.read source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro if-let ((var test) then &optional else) | |
"(if-let binding then else?) | |
binding => binding-form test | |
If test is true, evaluates then with binding-form bound to the value of | |
test, if not, yields else" | |
`(let ((,var ,test)) | |
(if ,var | |
,then | |
,else))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro when-let ((var test) &body body) | |
"(when-let binding body) | |
binding => binding-form test | |
When test is true, evaluates body with binding-form bound to the value of test" | |
`(let ((,var ,test)) | |
(when ,var | |
,@body))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro sublist (1st start &optional (size nil)) | |
"(sublist start size?) | |
Returns a list of the items in vector from start (inclusive) | |
to start + size (exclusive). If size is not supplied, | |
defaults to end of list." | |
`(loop for item in (nthcdr ,start ,1st) | |
,@(if size | |
`(for i from 1 to ,size)) | |
collect item)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; dump tree with a recursive lambda | |
(funcall | |
(fn dump-tree (e) | |
(if (atom e) | |
(format t "~A~%" e) | |
(mapc #'dump-tree e))) | |
'(1 (2 (3 (4) 5) 6) 7 (8 9))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Y组合子是Lambda演算的一部分,也是函数式编程的理论基础。 | |
它是一种方法/技巧,在没有赋值语句的前提下定义递归的匿名函数。 | |
即仅仅通过Lambda表达式这个最基本的“原子”实现循环/迭代。 | |
颇有道生一、一生二、二生三、三生万物的感觉。 | |
虽然Y组合子在理论上很优美,但在实际开发中并不会真的用到。 | |
想要了解Y组合子是什么,请参见维基百科:http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator | |
或者知乎上的回答:http://www.zhihu.com/question/20115649 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZSH在交互方面的确比Bash略胜一筹,但习惯了Bash下大小写无关补全等功能,需要对zsh的默认配置做一些调整。 |
OlderNewer