diff --git a/examples/download.ds b/examples/download.ds index 983dbf4..b824505 100644 --- a/examples/download.ds +++ b/examples/download.ds @@ -1,9 +1,10 @@ -cast = (download "https://api.sampleapis.com/futurama/cast") -characters = (download "https://api.sampleapis.com/futurama/characters") -episodes = (download "https://api.sampleapis.com/futurama/episodes") +raw_data = download("https://api.sampleapis.com/futurama/cast") +cast_data = from_json(raw_data) -cast_len = (length (from_json cast)) -characters_len = (length (from_json characters)) -episodes_len = (length (from_json episodes)) +names = [] -(output [cast_len, characters_len, episodes_len]) +for cast_member in cast_data { + names += cast_member:name +} + +assert_equal("Billy West", names:0) diff --git a/examples/fetch.ds b/examples/fetch.ds deleted file mode 100644 index b824505..0000000 --- a/examples/fetch.ds +++ /dev/null @@ -1,10 +0,0 @@ -raw_data = download("https://api.sampleapis.com/futurama/cast") -cast_data = from_json(raw_data) - -names = [] - -for cast_member in cast_data { - names += cast_member:name -} - -assert_equal("Billy West", names:0) diff --git a/examples/match.ds b/examples/match.ds deleted file mode 100644 index 2991c01..0000000 --- a/examples/match.ds +++ /dev/null @@ -1,12 +0,0 @@ -foo_or_bar = match random:boolean() { - true => "foo" - false => "bar" -} - -num = match random:integer() { - 1 => "one", - 2 => { "two" }, - * => "neither", -} - -[foo_or_bar, num] diff --git a/examples/option.ds b/examples/option.ds deleted file mode 100644 index 037017b..0000000 --- a/examples/option.ds +++ /dev/null @@ -1,22 +0,0 @@ -create_user = (fn email , name ) { - { - email = email - username = (either_or name email) - } -} - -(assert_equal - { - email = "bob@example.com" - username = "bob" - }, - (create_user "bob@example.com" some("bob")) -) - -(assert_equal - { - email = "sue@example.com" - username = "sue@example.com" - }, - (create_user "sue@example.com" none) -) diff --git a/examples/variables.ds b/examples/variables.ds deleted file mode 100644 index 7c00a11..0000000 --- a/examples/variables.ds +++ /dev/null @@ -1,10 +0,0 @@ -x = 1 -y = "hello dust!" -z = 42.0 -list = [3, 2, x] -big_list = [x, y, z, list] -foo = { - x = "bar" - y = 42 - z = 0 -} diff --git a/examples/while_loop.ds b/examples/while_loop.ds deleted file mode 100644 index d3ded4d..0000000 --- a/examples/while_loop.ds +++ /dev/null @@ -1,6 +0,0 @@ -i = 0 - -while i < 10 { - output(i) - i += 1 -} diff --git a/examples/yield.ds b/examples/yield.ds deleted file mode 100644 index 8369fdc..0000000 --- a/examples/yield.ds +++ /dev/null @@ -1,13 +0,0 @@ -add_one = (numbers <[int]>) <[int]> { - new_numbers = [] - - for number in numbers { - new_numbers += number + 1 - } - - new_numbers -} - -foo = [1, 2, 3] -> add_one - -assert_equal([2 3 4] foo)