[swift-evolution] About the PermutationGenerator
Susan Cheng
susan.doggie at gmail.com
Thu Dec 31 07:04:35 CST 2015
yes for sequences are not immutable. I get confused.
no for sequences should be definition of lists of values. Just
like Fibonacci sequence, we can calculate the values form the start of
the Fibonacci sequence one by one. But we are not accessing the values
of Fibonacci sequence.
A socket can be modeled as a sequence of bytes but socket(itself) is not
the sequence. It's just provide method to access the bytes sequences.
Dmitri Gribenko <gribozavr at gmail.com> 於 2015年12月31日星期四 寫道:
> On Thu, Dec 31, 2015 at 2:01 PM, Susan Cheng via swift-evolution <
> swift-evolution at swift.org
> <javascript:_e(%7B%7D,'cvml','swift-evolution at swift.org');>> wrote:
>
>> As I know SequenceType should have behaved as immutable structure and it
>> provides method to get a mutable GeneratorType which generates value from
>> start of sequence.
>
>
> Sequences are not immutable. A sequence is allowed to be consumed by
> iterating over its generator. If the type you have is a sequence, you can
> only assume that you can access the elements only once. For example, a
> socket can be modeled as a sequence of bytes. Once the bytes are consumed
> from the corresponding generator, they are gone from the sequence.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com
> <javascript:_e(%7B%7D,'cvml','gribozavr at gmail.com');>>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151231/ed64cb37/attachment.html>
More information about the swift-evolution
mailing list