added afind primitive
authorAndrea Griffini <agriff@tin.it>
Sun, 5 May 2013 20:40:30 +0000 (22:40 +0200)
committerAndrea Griffini <agriff@tin.it>
Sun, 5 May 2013 20:40:30 +0000 (22:40 +0200)
src/compiler.lisp

index 8421b16..0f87ec3 100644 (file)
     "if (i < 0 || i >= x.length) throw 'Out of range';" *newline*
     "return x[i] = " value ";" *newline*))
 
+(define-builtin afind (value array)
+  (js!selfcall
+    "var v = " value ";" *newline*
+    "var x = " array ";" *newline*
+    "return x.indexOf(v);" *newline*))
+
 (define-builtin get-internal-real-time ()
   "(new Date()).getTime()")