@@ -277,6 +277,7 @@ mod inner {
277277 /// - for values lower than `0` the first argument is smaller than the second argument
278278 /// - for values higher than `0` the first argument is greater than the second argument
279279 /// - for values equal to `0` the first argument is equal to the second argument
280+ #[ function( return_type = Vec <_>) ]
280281 pub fn sorted_by ( seq : SeqValue , comp : & mut VmCallable < ' _ > ) -> anyhow:: Result < Value > {
281282 let mut list: Vec < Value > = seq
282283 . try_into_iter ( )
@@ -334,6 +335,7 @@ mod inner {
334335 }
335336
336337 /// Enumerates the given sequence returning a list of tuples where the first element of the tuple is the index of the element in the input sequence.
338+ #[ function( return_type = Vec <_>) ]
337339 pub fn enumerate ( seq : SeqValue ) -> anyhow:: Result < Value > {
338340 Ok ( Value :: list (
339341 seq. try_into_iter ( )
@@ -370,6 +372,7 @@ mod inner {
370372 }
371373
372374 /// Filters the given sequence using the `predicate`.
375+ #[ function( return_type = Vec <_>) ]
373376 pub fn filter ( seq : SeqValue , predicate : & mut VmCallable < ' _ > ) -> anyhow:: Result < Value > {
374377 let mut out = Vec :: new ( ) ;
375378 for element in seq
@@ -514,6 +517,7 @@ mod inner {
514517 }
515518
516519 /// Applies the function to each element in a sequence returning the result as a list.
520+ #[ function( return_type = Vec <_>) ]
517521 pub fn map ( seq : SeqValue , function : & mut VmCallable < ' _ > ) -> anyhow:: Result < Value > {
518522 let mut out = Vec :: new ( ) ;
519523 for item in seq
@@ -526,6 +530,7 @@ mod inner {
526530 }
527531
528532 /// Applies a function to each item in a sequence, flattens the resulting sequences, and returns a single combined sequence.
533+ #[ function( return_type = Vec <_>) ]
529534 pub fn flat_map ( seq : SeqValue , function : & mut VmCallable < ' _ > ) -> anyhow:: Result < Value > {
530535 let mut out = Vec :: new ( ) ;
531536 for item in seq
@@ -557,6 +562,7 @@ mod inner {
557562 }
558563
559564 /// Returns the `k` sized combinations of the given sequence `seq` as a lazy iterator of tuples.
565+ #[ function( return_type = Iterator <Value >) ]
560566 pub fn combinations ( seq : SeqValue , k : i64 ) -> anyhow:: Result < Value > {
561567 let k = k as usize ;
562568 let iter = CombinationsIter :: new ( seq, k)
@@ -572,6 +578,7 @@ mod inner {
572578 }
573579
574580 /// Returns the `k` sized permutations of the given sequence `seq` as a list of tuples.
581+ #[ function( return_type = Vec <_>) ]
575582 pub fn permutations ( seq : SeqValue , k : i64 ) -> anyhow:: Result < Value > {
576583 let k = k as usize ;
577584 Ok ( Value :: list (
@@ -584,6 +591,7 @@ mod inner {
584591 }
585592
586593 /// Returns all prefixes of a sequence, each as a list.
594+ #[ function( return_type = Vec <_>) ]
587595 pub fn prefixes ( seq : SeqValue ) -> anyhow:: Result < Value > {
588596 // Special case for String — produce string prefixes instead of lists of chars.
589597 if let Value :: Object ( ref obj) = seq
@@ -611,6 +619,7 @@ mod inner {
611619 }
612620
613621 /// Returns all suffixes of a sequence, each as a list; for strings, returns all trailing substrings.
622+ #[ function( return_type = Vec <_>) ]
614623 pub fn suffixes ( seq : SeqValue ) -> anyhow:: Result < Value > {
615624 // Special case for String — produce string suffixes instead of lists of chars.
616625 if let Value :: Object ( ref obj) = seq
@@ -636,6 +645,7 @@ mod inner {
636645 }
637646
638647 /// Transposes a sequence of sequences, turning rows into columns, and returns the result as a list of lists.
648+ #[ function( return_type = Vec <_>) ]
639649 pub fn transposed ( seq : SeqValue ) -> anyhow:: Result < Value > {
640650 let main: Vec < Value > = seq
641651 . try_into_iter ( )
@@ -658,6 +668,7 @@ mod inner {
658668 }
659669
660670 /// Return a list of all windows, wrapping back to the first elements when the window would otherwise exceed the length of source list, producing tuples of size 2.
671+ #[ function( return_type = Vec <_>) ]
661672 pub fn circular_tuple_windows ( seq : SeqValue ) -> anyhow:: Result < Value > {
662673 Ok ( Value :: list (
663674 seq. try_into_iter ( )
@@ -671,6 +682,7 @@ mod inner {
671682 }
672683
673684 /// Returns a list of all size-2 windows in `seq`.
685+ #[ function( return_type = Vec <_>) ]
674686 pub fn pairwise ( seq : SeqValue ) -> anyhow:: Result < Value > {
675687 Ok ( Value :: list (
676688 seq. try_into_iter ( )
@@ -683,7 +695,7 @@ mod inner {
683695 }
684696
685697 /// Applies a function to each pair of consecutive elements in a sequence and returns the results as a list.
686- #[ function( name = "pairwise" ) ]
698+ #[ function( name = "pairwise" , return_type = Vec <_> ) ]
687699 pub fn pairwise_map ( seq : SeqValue , function : & mut VmCallable < ' _ > ) -> anyhow:: Result < Value > {
688700 let main: Vec < Value > = seq
689701 . try_into_iter ( )
@@ -697,6 +709,7 @@ mod inner {
697709 }
698710
699711 /// Returns a list of all contiguous windows of `length` size. The windows overlap. If the `seq` is shorter than size, the iterator returns no values.
712+ #[ function( return_type = Vec <_>) ]
700713 pub fn windows ( seq : SeqValue , length : i64 ) -> anyhow:: Result < Value > {
701714 let length = length as usize ;
702715 Ok ( Value :: list (
@@ -713,6 +726,7 @@ mod inner {
713726 ///
714727 /// The powerset of a set contains all subsets including the empty set and the full input set. A powerset has length `2^n` where `n` is the length of the input set.
715728 /// Each list produced by this function represents a subset of the elements in the source sequence.
729+ #[ function( return_type = Vec <_>) ]
716730 pub fn subsequences ( seq : SeqValue ) -> anyhow:: Result < Value > {
717731 Ok ( Value :: list (
718732 seq. try_into_iter ( )
@@ -724,7 +738,7 @@ mod inner {
724738 }
725739
726740 /// Return a list that represents the powerset of the elements of `seq` that are exactly `length` long.
727- #[ function( name = "subsequences" ) ]
741+ #[ function( name = "subsequences" , return_type = Vec <_> ) ]
728742 pub fn subsequences_len ( seq : SeqValue , length : i64 ) -> anyhow:: Result < Value > {
729743 let length = length as usize ;
730744 Ok ( Value :: list (
@@ -763,6 +777,7 @@ mod inner {
763777 /// [3,"c",false]
764778 /// ]
765779 /// ```
780+ #[ function( return_type = Vec <_>) ]
766781 pub fn multi_cartesian_product ( seq : SeqValue ) -> anyhow:: Result < Value > {
767782 let mut iterators = Vec :: new ( ) ;
768783 for elem in seq
@@ -786,6 +801,7 @@ mod inner {
786801
787802 /// Split the input sequence into evenly sized chunks. If the input length of the sequence
788803 /// is not dividable by the chunk_size the last chunk will contain fewer elements.
804+ #[ function( return_type = Vec <_>) ]
789805 pub fn chunks ( seq : SeqValue , chunk_size : usize ) -> anyhow:: Result < Value > {
790806 if chunk_size == 0 {
791807 return Err ( anyhow ! ( "chunk size must be non-zero" ) ) ;
0 commit comments