-
Notifications
You must be signed in to change notification settings - Fork 318
Sequence operations #14
Comments
Hi, Also, I didn't think that both |
Cool, glad to hear you are interested. I'll keep exploring different ideas to see if I can avoid the need to use
Actually they do (otherwise they would not work with for-in loops). The protocol inheritance is a bit convoluted, but you can see it for
I'll keep playing around with these ideas and get back to you. |
I'm pretty sure too there isn't a handier way (at least for the moment, Swift is still missing important pieces). |
Sorry, my mistake :-) I guess you could implement the Array and Dictionary methods via Sequence, for example, an array skip could be implemented as Anyhow, I'll get started! |
Just a quick update, I have implemented the following methods:
The 'take' methods were a bit more challenging! Anyhow, my feeling is that the ExSwift should only expose operations on As a result, I propose adding the following methods:
I'll also add some documentation about when you should use the sequence operations, and why some operations are omitted. |
I agree, but doesn't the same apply to |
I'm pretty sure they can be implemented lazily. I'll let you know how I progress! |
Hello, I think there is no need for FilterSequence struct, we can reuse global 'filter' function. extension SequenceOf
} |
Yes, that's correct, the documentation says clearly that |
In Xcode 6 Beta 4, Swift.filter no longer returns lazy Sequence, so it can't be used anymore. |
@nstepan oh, that is a bit of an odd and unexpected change! |
I just pushed a temporary fix. |
Hi! I saw this library mentioned on stack overflow, and I realised I had had a few things hanging around that were similar to what's in the |
Hi - are you interested in a contribution which adds
Sequence
operations to this library?The Swift
Sequence
is lazy evaluated, and as a result the various operations (take, skip, contains, ...) can be written in such as way that they do not have to evaluate the entire sequence to return their value.I've implemented a few operations here:
https://github.com/ColinEberhardt/ExSwift/blob/sequence-operations/ExSwift/Sequence.swift
With tests here:
https://github.com/ColinEberhardt/ExSwift/blob/sequence-operations/ExSwiftTests/ExSwiftSequenceTests.swift
Unfortunately because you cannot extend protocols, the only way I can find to add sequence operations is to extend
SequenceOf
, which as far as a I can tell adapts aSequence
returning a concrete type rather than a protocol.Anyhow, just wanted to get your thoughts before I get too stuck in to the implementation. If I add a decent suite of Sequence methods, would you want to include them in ExSwift?
The text was updated successfully, but these errors were encountered: