diff --git a/examples/projects/lambda.lisp b/examples/projects/lambda.lisp new file mode 100644 index 0000000..4c993d9 --- /dev/null +++ b/examples/projects/lambda.lisp @@ -0,0 +1,29 @@ +(resize 600 200) + +(clear) + +(def colors + ("#72dec2" "#316067")) + +(def picked-colors + ("#000" "#000" "#000" "#000" "#000" "#000" "#000" "#000" "#000")) + +(fill + (rect 0 0 600 200) + (gradient + (guide + (line 0 100 600 100)) colors)) + +(each picked-colors + (λ + (color id) + ( + (set picked-colors id + (pick + (guide + (pos + (mul id + (div 600 9)) 100))))))) + +(echo + (get picked-colors:1 "hex")) \ No newline at end of file diff --git a/index.html b/index.html index 57fff2b..fa4141c 100644 --- a/index.html +++ b/index.html @@ -1203,7 +1203,7 @@ function Library (client) { this.each = (arr, fn) => { // Run a function for each element in a list. for (let i = 0; i < arr.length; i++) { const arg = arr[i] - fn(arg) + fn(arg,i) } } this.map = (arr, fn) => { // Run a function on each element in a list. diff --git a/scripts/library.js b/scripts/library.js index 2f80e12..7337273 100644 --- a/scripts/library.js +++ b/scripts/library.js @@ -416,7 +416,7 @@ function Library (client) { this.each = (arr, fn) => { // Run a function for each element in a list. for (let i = 0; i < arr.length; i++) { const arg = arr[i] - fn(arg) + fn(arg,i) } }