@@ -1,7 +1,7 @@
1Elm.List = function() {
1Elm.List = function() {
3 var throwError = function(f) {
3 var throwError = function(f) {
4− throw "Function '" + f + "' expecting a list!";
4+ throw new Error("Function '" + f + "' expecting a list!");
7 function length(xs) {
7 function length(xs) {
@@ -46,19 +46,19 @@ Elm.List = function() {
46 var minimum = foldl1(function(x) { return function(y) { return Math.min(x,y) } });
46 var minimum = foldl1(function(x) { return function(y) { return Math.min(x,y) } });
47 function head(v) {
47 function head(v) {
48 if (v[0] !== "Cons") {
48 if (v[0] !== "Cons") {
49− throw "Error: 'head' only accepts lists of length greater than one.";
49+ throw new Error("Error: 'head' only accepts lists of length greater than one.");
51 return v[1];
51 return v[1];
53 function tail(v) {
53 function tail(v) {
54 if (v[0] !== "Cons") {
54 if (v[0] !== "Cons") {
55− throw "Error: 'tail' only accepts lists of length greater than one.";
55+ throw new Error("Error: 'tail' only accepts lists of length greater than one.");
57 return v[2];
57 return v[2];
59 function last(v) {
59 function last(v) {
60 if (v[0] !== "Cons") {
60 if (v[0] !== "Cons") {
61− throw "Error: 'last' only accepts lists of length greater than one.";
61+ throw new Error("Error: 'last' only accepts lists of length greater than one.");
63 var out = v[1];
63 var out = v[1];
64 while (v[0] === "Cons") {
64 while (v[0] === "Cons") {
@@ -129,7 +129,7 @@ Elm.List = function() {
130 function foldr1(f) {
130 function foldr1(f) {
131 return function(xs) {
131 return function(xs) {
132− if (xs[0] === "Nil") { throw "'foldr1' requires an non-empty list." }
132+ if (xs[0] === "Nil") { throw new Error("'foldr1' requires an non-empty list.") }
133 if (xs[0] !== "Cons") { throwError('foldr1'); }
133 if (xs[0] !== "Cons") { throwError('foldr1'); }
134 var arr = [];
134 var arr = [];
135 while (xs[0] === "Cons") {
135 while (xs[0] === "Cons") {
@@ -165,7 +165,7 @@ Elm.List = function() {
165 function scanl1(f) {
165 function scanl1(f) {
166 return function(xs) {
166 return function(xs) {
167 if (xs[0] !== "Cons") {
167 if (xs[0] !== "Cons") {
168− throw "Error: 'scanl1' requires a list of at least length 1.";
168+ throw new Error("Error: 'scanl1' requires a list of at least length 1.");
170 return scanl(f)(xs[1])(xs[2]);
170 return scanl(f)(xs[1])(xs[2]);