Created
November 26, 2012 22:27
-
-
Save raimohanska/4151074 to your computer and use it in GitHub Desktop.
Some array helpers in Roy
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 jsarray xs = (Array.apply null xs) | |
let length xs = (jsarray xs).length | |
let empty xs = (length xs) == 0 | |
let concat xs ys = (jsarray xs).concat ys | |
let cons x xs = concat [x] xs | |
let head xs = xs@0 | |
let tail xs = (jsarray xs).slice 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OOPS! Sorry.
Array.apply null xs actually fails for 1-sized arrays.