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
add a b = a + b | |
turboDrop n xs = if n <= 0 || null xs | |
then xs | |
else turboDrop (n -1)(tail xs) | |
fu = print "abc" | |
data Phones = Iphone | Htc_one |
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
* General form | |
Command (parameters*)\n | |
* General errors | |
ERR_INVALID_SEQUENCE 2 | |
ERR_INVALID_COMMAND 4 | |
* Commands | |
JOIN | |
Resp: OK [GO | WAIT] GAME_NUMBER |
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
66a4a70f a087d7cf b6a22bf7 f9614ee8 16cfa25e 17e4c020 67dbbc01 ce6d52e7 |
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
<6d619398 75fd80e6 d7d57bc0 1bd852cd a8e17371 947c9d43 c9245ca2 c7cf46cc> |
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
package main | |
import ("fmt" | |
"net/http") | |
type Endpoint struct { | |
address string | |
code int | |
} |
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
function foo () | |
return coroutine.yield("ho ho ho") | |
end | |
co = coroutine.create(function (a) | |
return foo() * a | |
end) | |
print("intermediate result", coroutine.resume(co, 3)) | |
print("final result", coroutine.resume(co, 7)) |
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
(testing + | |
[1] [1] "single result is noop" | |
[1 2] [3] "two values are added" | |
[1 2 3] [6] "three values are added" | |
[] [0] "no values, zero") |
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
;idea from the book onlisp, pag 30 | |
(defn rev [nums] | |
(let [f (fn [coll res] | |
(if (empty? coll) | |
res | |
(recur (drop-last coll) (conj res (last coll)))))] | |
(f nums []))) |
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
;exercise from http://programmingpraxis.com/2010/10/08/zellers-congruence/ | |
;formula from http://en.wikipedia.org/wiki/Zeller%27s_congruence | |
(defn month-id [month] | |
(+ 3 | |
(mod (+ month 9) 12))) | |
(defn year-of-century [year] | |
(mod year 100)) |
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
(let ((counter 0)) | |
(defun new-id () | |
(incf counter)) | |
(defun reset-id () | |
(setq counter 0))) |
NewerOlder