Skip to content

Commit 86a1dff

Browse files
authored
Merge pull request #288 from sogaiu/tweak-example-retuns-and-formatting
Tweak examples: *, apply, and product
2 parents 18dc7cd + 2c46351 commit 86a1dff

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/_42.janet

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(*) # -> 1
22
(* 10) # -> 10
33
(* 10 20) # -> 200
4-
(* 1 2 3 4 5 6 7) #-> 5040
4+
(* 1 2 3 4 5 6 7) # -> 5040
55

66
# Can take product of array with splice, but 'product' is better
7-
(* ;(range 1 20)) #-> 1.21645e+17
8-
(product (range 1 20)) #-> 1.21645e+17
7+
(* ;(range 1 20)) # -> 1.21645100408832e+17
8+
(product (range 1 20)) # -> 1.21645100408832e+17

examples/apply.janet

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(apply + (range 10)) # -> 45
22
(apply + []) # -> 0
33
(apply + 1 2 3 4 5 6 7 [8 9 10]) # -> 55
4-
(apply + 1 2 3 4 5 6 7 8 9 10) # -> error: expected array|tuple, got number
4+
(apply + 1 2 3 4 5 6 7 8 9 10) # -> error: expected array or tuple, got 10
55

66
# Can also be used to call macros like functions.
77
# Will return the macro expanded code of the original macro.

examples/product.janet

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(product (range 1 10)) # -> 362880
55

66
# Product over byte values [0-255] in a string
7-
(product "hello") # -> 1.35996e+10
7+
(product "hello") # -> 13599570816
88

99
# Product over values in a table or struct
1010
(product {:a 1 :b 2 :c 4}) # -> 8

0 commit comments

Comments
 (0)