Created
June 20, 2012 16:16
-
-
Save dalmaer/2960736 to your computer and use it in GitHub Desktop.
Samples for LispyScript
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
// All Javascript functions, objects and literals can be used in LispyScript. | |
(Array.prototype.forEach.call [1, 2, 3] | |
(function (elem index list) | |
(console.log elem))) | |
// You can access object methods and properties using the "." notation. | |
(console.log (.greet {greet: "hello"})) | |
// You can also use the 'get' expression to access a property of an object. | |
(console.log (get "greet" {greet: "hello"})) | |
(console.log (get 1 [1, 2, 3])) | |
// You can 'set' variables too. | |
(set window.onload (function () (alert "Page Loaded"))) | |
// Now let us create a Lisp like 'let' macro in LispyScript. | |
(macro let (names vals rest...) | |
((function ~names ~rest...) ~@vals)) | |
(let (name email tel) ("John" "[email protected]" "555-555-5555") | |
(console.log name) | |
(console.log email) | |
(console.log tel)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment