Skip to content

Commit

Permalink
Add toIter() and fromIter() to all collections (#49)
Browse files Browse the repository at this point in the history
* Add 'toIter()' and 'fromIter()' to all collections

* Remove extraneous function
  • Loading branch information
rvanasa authored Dec 17, 2024
1 parent c537dfd commit d6f3ab0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Array.mo
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ module {

public func singleton<T>(element : T) : [T] = [element];

public func fromIter<T>(iter : Iter.Iter<T>) : [T] {
todo()
};

public func toIter<T>(array : [T]) : Iter.Iter<T> = array.vals();

public func vals<T>(array : [T]) : Iter.Iter<T> = array.vals();
Expand Down
3 changes: 2 additions & 1 deletion src/Iter.mo
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/// Iterators

import Type "IterType";
import Order "Order";
import { nyi = todo } "Debug";

module {

public type Iter<T> = { next : () -> ?T };
public type Iter<T> = Type.Iter<T>;

public class range(fromInclusive : Int, toExclusive : Int) {
todo()
Expand Down
4 changes: 4 additions & 0 deletions src/Stack.mo
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ module {
todo()
};

public func fromIter<T>(iter : Iter.Iter<T>) : Stack<T> {
todo()
};

public func toIter<T>(stack : Stack<T>) : Iter.Iter<T> {
todo()
};
Expand Down
4 changes: 0 additions & 4 deletions src/pure/Queue.mo
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ module {

public func toIter<T>(queue : Queue<T>) : Iter.Iter<T> = vals(queue);

public func fromIter<T>(iter : Iter.Iter<T>) : Queue<T> {
todo()
};

public func vals<T>(queue : Queue<T>) : Iter.Iter<T> {
todo()
};
Expand Down

0 comments on commit d6f3ab0

Please sign in to comment.