@grain/stdlib 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/array.gr +56 -1
- package/array.md +83 -0
- package/bigint.md +30 -30
- package/buffer.gr +24 -22
- package/float32.md +3 -3
- package/float64.md +3 -3
- package/immutablepriorityqueue.gr +332 -0
- package/immutablepriorityqueue.md +248 -0
- package/list.gr +73 -0
- package/list.md +110 -0
- package/map.gr +1 -2
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +41 -0
- package/number.md +80 -5
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +241 -0
- package/priorityqueue.md +279 -0
- package/regex.gr +5 -5
- package/runtime/compare.gr +178 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +1 -2
- package/runtime/numbers.gr +307 -68
- package/runtime/numbers.md +24 -0
- package/set.gr +1 -2
- package/string.gr +97 -15
- package/string.md +65 -1
- package/sys/file.gr +3 -3
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +2 -2
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/list.md
CHANGED
|
@@ -819,6 +819,116 @@ Returns:
|
|
|
819
819
|
|----|-----------|
|
|
820
820
|
|`List<a>`|The new list with only unique values|
|
|
821
821
|
|
|
822
|
+
### List.**zip**
|
|
823
|
+
|
|
824
|
+
<details disabled>
|
|
825
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
826
|
+
No other changes yet.
|
|
827
|
+
</details>
|
|
828
|
+
|
|
829
|
+
```grain
|
|
830
|
+
zip : (List<a>, List<b>) -> List<(a, b)>
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
Produces a new list filled with tuples of elements from both given lists.
|
|
834
|
+
The first tuple will contain the first item of each list, the second tuple
|
|
835
|
+
will contain the second item of each list, and so on.
|
|
836
|
+
|
|
837
|
+
Calling this function with lists of different sizes will cause the returned
|
|
838
|
+
list to have the length of the smaller list.
|
|
839
|
+
|
|
840
|
+
Parameters:
|
|
841
|
+
|
|
842
|
+
|param|type|description|
|
|
843
|
+
|-----|----|-----------|
|
|
844
|
+
|`list1`|`List<a>`|The list to provide values for the first tuple element|
|
|
845
|
+
|`list2`|`List<b>`|The list to provide values for the second tuple element|
|
|
846
|
+
|
|
847
|
+
Returns:
|
|
848
|
+
|
|
849
|
+
|type|description|
|
|
850
|
+
|----|-----------|
|
|
851
|
+
|`List<(a, b)>`|The new list containing indexed pairs of `(a, b)`|
|
|
852
|
+
|
|
853
|
+
Examples:
|
|
854
|
+
|
|
855
|
+
```grain
|
|
856
|
+
List.zip([1, 2, 3], [4, 5, 6]) // [(1, 4), (2, 5), (3, 6)]
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
```grain
|
|
860
|
+
List.zip([1, 2, 3], [4, 5]) // [(1, 4), (2, 5)]
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### List.**zipWith**
|
|
864
|
+
|
|
865
|
+
<details disabled>
|
|
866
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
867
|
+
No other changes yet.
|
|
868
|
+
</details>
|
|
869
|
+
|
|
870
|
+
```grain
|
|
871
|
+
zipWith : (((a, b) -> c), List<a>, List<b>) -> List<c>
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Produces a new list filled with elements defined by applying a function on
|
|
875
|
+
pairs from both given lists. The first element will contain the result of
|
|
876
|
+
applying the function to the first elements of each list, the second element
|
|
877
|
+
will contain the result of applying the function to the second elements of
|
|
878
|
+
each list, and so on.
|
|
879
|
+
|
|
880
|
+
Calling this function with lists of different sizes will cause the returned
|
|
881
|
+
list to have the length of the smaller list.
|
|
882
|
+
|
|
883
|
+
Parameters:
|
|
884
|
+
|
|
885
|
+
|param|type|description|
|
|
886
|
+
|-----|----|-----------|
|
|
887
|
+
|`fn`|`(a, b) -> c`|The function to apply to pairs of elements|
|
|
888
|
+
|`list1`|`List<a>`|The list whose elements will each be passed to the function as the first argument|
|
|
889
|
+
|`list2`|`List<b>`|The list whose elements will each be passed to the function as the second argument|
|
|
890
|
+
|
|
891
|
+
Returns:
|
|
892
|
+
|
|
893
|
+
|type|description|
|
|
894
|
+
|----|-----------|
|
|
895
|
+
|`List<c>`|The new list containing elements derived from applying the function to pairs of input list elements|
|
|
896
|
+
|
|
897
|
+
Examples:
|
|
898
|
+
|
|
899
|
+
```grain
|
|
900
|
+
List.zipWith((a, b) => a + b, [1, 2, 3], [4, 5, 6]) // [5, 7, 9]
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
```grain
|
|
904
|
+
List.zipWith((a, b) => a * b, [1, 2, 3], [4, 5]) // [4, 10]
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
### List.**unzip**
|
|
908
|
+
|
|
909
|
+
<details disabled>
|
|
910
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
911
|
+
No other changes yet.
|
|
912
|
+
</details>
|
|
913
|
+
|
|
914
|
+
```grain
|
|
915
|
+
unzip : List<(a, b)> -> (List<a>, List<b>)
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
Produces two lists by splitting apart a list of tuples.
|
|
919
|
+
|
|
920
|
+
Parameters:
|
|
921
|
+
|
|
922
|
+
|param|type|description|
|
|
923
|
+
|-----|----|-----------|
|
|
924
|
+
|`list`|`List<(a, b)>`|The list of tuples to split|
|
|
925
|
+
|
|
926
|
+
Returns:
|
|
927
|
+
|
|
928
|
+
|type|description|
|
|
929
|
+
|----|-----------|
|
|
930
|
+
|`(List<a>, List<b>)`|An list containing all elements from the first tuple element, and a list containing all elements from the second tuple element|
|
|
931
|
+
|
|
822
932
|
### List.**drop**
|
|
823
933
|
|
|
824
934
|
<details disabled>
|
package/map.gr
CHANGED
|
@@ -504,8 +504,7 @@ export let reject = (predicate, map) => {
|
|
|
504
504
|
filter((key, value) => !predicate(key, value), map)
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
// TODO: Should return a Record type instead of a Tuple
|
|
508
|
-
// Waiting on https://github.com/grain-lang/grain/issues/190
|
|
507
|
+
// TODO(#190): Should return a Record type instead of a Tuple
|
|
509
508
|
/**
|
|
510
509
|
* Provides data representing the internal state state of the map.
|
|
511
510
|
*
|