sum1(1, 2, 3) == 6
1 1
2 2
3 Fizz
4 4
| (ns tokichat.core | |
| (:use org.httpkit.server) | |
| (:gen-class)) | |
| (defn handler [req] | |
| (with-channel req channel | |
| (on-close channel (fn [status] | |
| (println "channel closed"))) |
| """ | |
| Extremely crude example of a timing attack | |
| """ | |
| import time | |
| import timeit | |
| actualPassword = '0BEA0239' | |
| def checkpassword(passwd): |
| let numberToTokiPona num = | |
| let rec addNum num str = | |
| if num >= 2 then addNum (num-2) (str + "twu ") | |
| else if num = 1 then addNum (num-1) (str + "wan ") | |
| else str | |
| if num > 0 then addNum num "" | |
| else "ala" | |
| (numberToTokiPona 19) |> printfn "%s" |
| open System.Threading | |
| type ChatMessage = | |
| | SendMessage of string | |
| | GetContent of AsyncReplyChannel<string list> | |
| let agent = MailboxProcessor.Start(fun agent -> | |
| let rec loop (state : string list) = async { | |
| printfn "List length is now %d" state.Length |
| open FSharp.Data | |
| open System.Threading | |
| ["http://bbc.co.uk"; "http://www.google.co.uk"] | |
| |> List.map (fun str -> | |
| async { | |
| let! html = Http.AsyncRequestString(str) | |
| return sprintf "bbc len %d" html.Length | |
| } | |
| ) |
| let numberToTokiPona num = | |
| let rec addNum num str = | |
| if num >= 2 then addNum (num-2) (str ^ "twu ") | |
| else if num = 1 then addNum (num-1) (str ^ "wan ") | |
| else str | |
| in | |
| if num > 0 then addNum num "" | |
| else "ala";; | |
| print_string (numberToTokiPona 19);; |
| (defn numberToTokiPona [num] | |
| (clojure.string/join " " | |
| (loop [n num strs []] | |
| (cond | |
| (> n 1) (recur (- n 2) (conj strs "twu")) | |
| (= n 1) (recur (- n 1) (conj strs "wan")) | |
| :else strs)))) |
| tokiPona = lambda num: (num / 2) * "twu " + ("wan" if num % 2 else "") |
| (defmacro pln [& args] | |
| (let [operator-count (dec (/ (count args) 2)) | |
| operators (take operator-count args) | |
| values (drop operator-count args) | |
| op-vals (map vector operators (next values))] | |
| (loop [form (first values) | |
| op-vals op-vals] | |
| (if (not-empty op-vals) |