Posted 17 June 2013 - 10:02 PM
Okay, so I'm working on this project and I need people to translate this array into their favourite programming languages.
You need to put it in a readable format and exactly how you would write it if you were to declare it (so it actually compiles/executes).
Please no esoteric programming languages.
Thank you very much!
Here is the array in JSON format (if you don't understand/know JSON then check the spoiler):
What I have so far:
You need to put it in a readable format and exactly how you would write it if you were to declare it (so it actually compiles/executes).
Please no esoteric programming languages.
Thank you very much!
Here is the array in JSON format (if you don't understand/know JSON then check the spoiler):
{
"strVal":"Hello world!",
"intVal":42,
"floatVal":3.14,
"boolVal":false,
"nullVal":null,
"0":"randomValue",
"arrayCeption":[
"Hello world!",
42,
3.14,
false,
null
]
}
What I have so far:
Spoiler
Lua (by Shazz):
array = {
strVal = 'Hello world!',
intVal = 42,
floatVal = 3.14,
boolVal = false,
nullVal = nil,
'randomValue',
arrayCeption = {
'Hello world!',
42,
3.14,
false,
nil
}
}
PHP (by Shazz):
$array = array(
'strVal' => 'Hello world!',
'intVal' => 42,
'floatVal' => 3.14,
'boolVal' => false,
'nullVal' => NULL,
'randomValue',
'arrayCeption' => array(
'Hello world!',
42,
3.14,
false,
NULL
)
);
Javascript (same as JSON pretty much) (by Shazz):
var array = {
"strVal":"Hello world!",
"intVal":42,
"floatVal":3.14,
"boolVal":false,
"nullVal":null,
"0":"randomValue",
"arrayCeption":[
"Hello world!",
42,
3.14,
false,
null
]
}
Java (by Engineer):
import java.util.HashMap;
public class Main {
public static void main(String[] args){
HashMap<String, Object> table = new HashMap<String, Object>();
table.put("strVal", "Hello world!");
table.put("intVal", 42);
table.put("floatVal", 3.14);
table.put("boolVal", false);
table.put("nullVal", null);
table.put("0", "randomValue");
table.put("arrayCeption", new Object[] {"Hello world!", 42, 3.14, false, null} );
}
}
Python (by Kingdaro):
arr = dict(
strVal = 'Hello world!',
intVal = 42,
floatVal = 3.14,
boolVal = False,
nullVal = None,
'0' = 'randomValue',
arrayCeption = ['Hello world!', 42, 3.14, false, None]
)
Ruby (by Kingdaro):
arr = {
'strVal': 'Hello world!',
'intVal': 42,
'floatVal': 3.14,
'boolVal': false,
'nullVal': nil,
'0': 'randomValue',
'arrayCeption': ['Hello world!', 42, 3.14, false, nil]
}