All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.unzip.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
"Given a stream of tuples, return two streams. The
 first stream produces the first elements of the
 given tuples, and the second stream produces the
 remaining elements of the given tuples.
 
 Thus:
 
     tuples[i] == [unzip(tuples)[0][i], 
                  *unzip(tuples)[1][i]]"
tagged("Streams")
shared [Iterable, Iterable] 
unzip
        (Iterable,Absent> tuples)
        given Tail satisfies Element[]
        given Absent satisfies Null
        => [tuples.map((Tuple tuple) 
                        => tuple.first),
            tuples.map((Tuple tuple) 
                        => tuple.rest)];

"Given a stream of pairs, return two streams. The
 first stream produces the first elements of the
 given pairs, and the second stream produces the
 second elements of the given pairs.
 
 Thus:
 
     pairs[i] == [unzipPairs(pairs)[0][i], 
                  unzipPairs(pairs)[1][i]]"
tagged("Streams")
shared [Iterable, Iterable] 
unzipPairs
        (Iterable<[First,Second],Absent> pairs)
        given Absent satisfies Null
        => [pairs.map(([First,Second] pair) => pair[0]),
            pairs.map(([First,Second] pair) => pair[1])];

"Given a stream of entries, return two streams. The
 first stream produces the keys of the given entries, 
 and the second stream produces the items of the given 
 entries.
 
 Thus:
 
     entries[i] == unzipEntries(entries)[0][i] 
                -> unzipEntries(entries)[1][i]"
tagged("Streams")
shared [Iterable, Iterable] 
unzipEntries
        (Iterable<Item>,Absent> entries)
        given Key satisfies Object
        given Absent satisfies Null
        => [entries.map(Entry.key),
            entries.map(Entry.item)];




© 2015 - 2024 Weber Informatics LLC | Privacy Policy