@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/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
  *