F.E.L.T.

Functionally Equivalent Language Translation

ARRAY / []

(array)                         ; an empty array
[]                              ; an empty array
(defvar foo [1])                ; contains number 1, length 1
(defvar foo (array 1 :x "3"))   ; contains number 1, 'x' and "3"
(defvar foo [ (+ 1 2) (time)]   ; contains (1+2) and the current time

The ARRAY instruction has the short-form []. You can place anything inside the square brackets that evaluates to something that will be acceptable to the selected back-end coder. Do not use commas. Repeat, do not use commas to separate the values. The items are white-space delimited. If the target language only allows homogeneous arrays then you will have to take that into consideration!


Creating an array is very simple in FELT, you just use the ARRAY instruction or you can use the short-form, square brackets. The choice of square brackets means that if you know JSON, you already know how to code array declarations in FELT.

FELT places no restrictions on what you can put inside an array as it has no idea on what the back-end coder will allow until the process reaches that stage.

Examples

Here are some examples in PHP and javaScript so that you can see what you get. As stated, FELT itself places absolutely no restrictions on what you can place inside an array; the onus is on you as the developer to know what you are doing and how you are going to be rendering out the code in the future.

There are no portability notes to take into consideration when using this instruction. The declarations can be as simple or as complex as you want to make the. Let's convert the following into PHP and then javaScript:

(defvar foo  (array (array 1 2) (array 3 4)))
(defvar bar  [ [1 2][3 4]])
(defvar baz  [ (array 10 20) [ 42 (array "Hello") ] "World"])

The above declarations produce this when translated to PHP:

$foo = array(array(1, 2), array(3, 4));
$bar = array(array(1, 2), array(3, 4));
$baz = array(array(10, 20), array(42, array("Hello")), "World");

And this when rendered as javaScript:

var foo = [[1, 2], [3, 4]];
var bar = [[1, 2], [3, 4]];
var baz = [[10, 20], [42, ["Hello"]], "World"];