Skip to content

Instantly share code, notes, and snippets.

@supersym
Last active December 17, 2015 10:29
Show Gist options
  • Save supersym/5595143 to your computer and use it in GitHub Desktop.
Save supersym/5595143 to your computer and use it in GitHub Desktop.
Some wisp snippets I probably shouldn't loose

Separation of functions through modules:

(import [read-from-string] "./reader")
(import [meta with-meta symbol? symbol keyword? keyword namespace
         unquote? unquote-splicing? quote? syntax-quote? name gensym pr-str] "./ast")
(import [empty? count list? list first second third rest cons conj
         reverse reduce vec last
         map filter take concat] "./sequence")
(import [odd? dictionary? dictionary merge keys vals contains-vector?
         map-dictionary string? number? vector? boolean? subs re-find
         true? false? nil? re-pattern? inc dec str char int = ==] "./runtime")
(import [split join upper-case replace] "./string")

Export Vars to the module scope

(def version "0.0.1")
(def isMaster (== true (require "cluster")))
(def num-cpus (:length (.cpus (require "os"))))
(def filetypes {:litcoffee ".litcoffee .coffee.md" :coffee ".coffee"
                :wisp ".wisp":json ".json" :cson "cson"})

Special form (. object method arg1 arg2) -> (object.method arg1 arg2)

(console.log (. (. (require "http") createServer
 (fn [request response]
  (. response writeHead 200)
  (. response end "hello world"))) listen 8000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment