Skip to content

Instantly share code, notes, and snippets.

View knjname's full-sized avatar
💭
🐙

knjname knjname

💭
🐙
View GitHub Profile
# 以下は1から3の文字をただ印字するつまらないプログラムである。
# 問題なし
# => 1 2 3
for i in [1..3]
console.log i
# 問題なし
# => 1 2 3
for i in [1..3]
@knjname
knjname / internalBindings.coffee
Created August 28, 2012 09:59
internalBindings.coffee
{hogeFunc, fugaFunc} = do =>
helperFunc = () -> # なんか
hogeFunc : () -> helperFunc()
fugaFunc : () -> helperFunc(helperFunc())
@knjname
knjname / ZFCNaturalNumber.coffee
Created August 30, 2012 02:09
ZFCNaturalNumber.coffee
zero = []
num = (n) ->
if n is 0
zero
else
prev = num(n-1)
[prev..., [prev]]
for i in [0..10]
firstThis = (fn) -> (head, args...) -> fn.call(head, head, args...)
about = (fn, argslist) -> fn.apply null, args for args in argslist
Function toJSON$(ByVal value)
Select Case TypeName(value)
Case "Dictionary"
toJSON$ = dict2JSON(value)
Case "Collection", "Variant()"
toJSON$ = col2JSON(value)
Case Else
toJSON$ = JSQuote(value)
End Select
public class NumberUnderscore {
public static void main(String[] args) {
int a;
a = 222_222;
a = 0b00_00; // binary literal
a = 0_2; // octal
// a = 0_9; illegal octal number
// a = 3333._222; illegal
// a = 2222_.222; illegal
public class TryWithResources {
public static AutoCloseable closeable(final String name) {
return new AutoCloseable() {
@Override
public void close() throws Exception {
System.out.println(name);
}
};
counter = (i) -> -> i++
a = counter 0
b = counter 0
console.log a()
console.log a()
console.log b()
@at = (namespace, fn = ->) =>
root = @
for spc in namespace.split /\./g
root = root[spc] ?= {}
fn.call root
root
@at 'util.math', ->
@square = (x) -> x * x