Code Monkey home page Code Monkey logo

ki's Introduction

ki

lisp + mori, sweet.js

ki

See ki-lang.org for more information.

ki is a lisp with Clojure data structures and semantics that can be intermixed with Javascript code at any level.

ki is a thin macro layer on top of mori plus a few constructs.

ki is in flux, feel free to test it out but expect glitches.

Currently available functions / special forms

All of mori.

The following list of functions / special forms

[] {} [$ ] {$ } add and apply atom bind catch chain cond def defmethod defmulti 
defn deref div do doto eq falsey finally fn fnth geq gt if if_not js leq letc 
letv lt loop mod mul neq nil not ns or prn recur reset str sub swap threadf 
threadl truthy try use when when_not while 

Take a look at the tests to keep up with the latest additions.

Examples

Require ki (this in turns expands into an appropriate require for mori)

ki require core

Mori's persistent data structures and Clojure(Script)-like api at your fingertips

var foo = ki (vector 1 2 3)
ki (conj foo 4)
// => [1 2 3 4]

Plus lambdas

ki (map (fn [a] (inc a)) (range 5))
// => (1 2 3 4 5)

Interoperability: write js in a ki form

var fn1 = ki (js function (a,b) { return a + b + 2; })

at any level - e.g. you can use infix where it makes sense

var fn2 = ki (fn [a b] (js a + b + 2))

and you can use ki wherever in js code

function somefunc (a) {
  ki (clj_to_js (filter (fn [el] (is_even el)) (range a))).forEach(function(el) {
      console.log(el);
      });
  return [0, 1, 2, 3, 4].filter(ki (fn [el] (is_even el)));
}
console.log(somefunc(5));
// => 0 
// => 2 
// => 4 
// [0 2 4]

Like a pro

ki (take 6 (map (fn [x] (js x * 2)) (range 1000)))
// => (0 2 4 6 8 10)

Get it

$ npm install -g ki

All set. Now to compile a JavaScript file containing ki code into a plain JavaScript file do

$ ki -o foo_build.js foo.js

To watch the file and have it automatically compiled whenever the file changes on disk

$ ki -w -o foo_build.js foo.js

License

MIT license http://www.opensource.org/licenses/mit-license.php/

Copyright (C) 2014 Luca Antiga http://lantiga.github.io

ki's People

Contributors

lantiga avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.