- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
LinearSeq and head/tail decomposition
Thu, 2011-06-23, 01:34
If LinearSeq is the trait that denotes efficient head/tail splitting, why is there no extractor like :: for LinearSeq? Am I missing something in the library?
Thu, 2011-06-23, 13:37
#2
Re: LinearSeq and head/tail decomposition
what would you think of an extractor named +: defined for linearseq? I'll run some performance tests.
On Jun 23, 2011 3:35 AM, "martin odersky" <martin.odersky@epfl.ch> wrote:> On Thu, Jun 23, 2011 at 2:33 AM, Josh Suereth <joshua.suereth@gmail.com>wrote:
>
>> If LinearSeq is the trait that denotes efficient head/tail splitting, why
>> is there no extractor like :: for LinearSeq? Am I missing something in the
>> library?
>
>
> We wanted to keep to the principle that extractors mirror constructors.
> Since only list has '::', it made sense to restrict the extractor to lists.
> One could
> think of defining '::' more generally, but then, that would be backwards
> incompatible, and I do not know what the performance implications for list
> would be.
>
> Cheers
>
> -- Martin
Thu, 2011-06-23, 14:37
#3
Re: LinearSeq and head/tail decomposition
On 23 June 2011 13:29, Josh Suereth <joshua.suereth@gmail.com> wrote:
what would you think of an extractor named +: defined for linearseq? I'll run some performance tests.
I was thinking of exactly the same thing... Performance aside though, is there any reason not to pull it further up the hierarchy, to Seq?
On Jun 23, 2011 3:35 AM, "martin odersky" <martin.odersky@epfl.ch> wrote:
> On Thu, Jun 23, 2011 at 2:33 AM, Josh Suereth <joshua.suereth@gmail.com>wrote:
>
>> If LinearSeq is the trait that denotes efficient head/tail splitting, why
>> is there no extractor like :: for LinearSeq? Am I missing something in the
>> library?
>
>
> We wanted to keep to the principle that extractors mirror constructors.
> Since only list has '::', it made sense to restrict the extractor to lists.
> One could
> think of defining '::' more generally, but then, that would be backwards
> incompatible, and I do not know what the performance implications for list
> would be.
>
> Cheers
>
> -- Martin
--
Kevin Wright
gtalk / msn : kev.lee.wright@gmail.comkev.lee.wright@gmail.commail: kevin.wright@scalatechnology.com
vibe / skype: kev.lee.wrightquora: http://www.quora.com/Kevin-Wright
twitter: @thecoda
"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
Thu, 2011-06-23, 15:17
#4
Re: LinearSeq and head/tail decomposition
You could go all the way to Traversable. I'm more of the opinion that doing head/tail decompositional algorithms belongs at LinearSeq *for* performance reasons. LinearSeq is supposed to guarantee 'efficient' head/tail decomposition, so it should support a handy mechanism to create these algorithms for all such collections.
I think if you wanted to use Seq or higher, different styles of algorithms will serve you better. After all, why have a rich collection hierarchy with performance 'pseduo-guarantees' if we don't plan to leverage that?
- Josh
On Thu, Jun 23, 2011 at 9:30 AM, Kevin Wright <kev.lee.wright@gmail.com> wrote:
I think if you wanted to use Seq or higher, different styles of algorithms will serve you better. After all, why have a rich collection hierarchy with performance 'pseduo-guarantees' if we don't plan to leverage that?
- Josh
On Thu, Jun 23, 2011 at 9:30 AM, Kevin Wright <kev.lee.wright@gmail.com> wrote:
On 23 June 2011 13:29, Josh Suereth <joshua.suereth@gmail.com> wrote:
what would you think of an extractor named +: defined for linearseq? I'll run some performance tests.
I was thinking of exactly the same thing... Performance aside though, is there any reason not to pull it further up the hierarchy, to Seq?
On Jun 23, 2011 3:35 AM, "martin odersky" <martin.odersky@epfl.ch> wrote:
> On Thu, Jun 23, 2011 at 2:33 AM, Josh Suereth <joshua.suereth@gmail.com>wrote:
>
>> If LinearSeq is the trait that denotes efficient head/tail splitting, why
>> is there no extractor like :: for LinearSeq? Am I missing something in the
>> library?
>
>
> We wanted to keep to the principle that extractors mirror constructors.
> Since only list has '::', it made sense to restrict the extractor to lists.
> One could
> think of defining '::' more generally, but then, that would be backwards
> incompatible, and I do not know what the performance implications for list
> would be.
>
> Cheers
>
> -- Martin
--
Kevin Wright
gtalk / msn : kev.lee.wright@gmail.comkev.lee.wright@gmail.commail: kevin.wright@scalatechnology.com
vibe / skype: kev.lee.wrightquora: http://www.quora.com/Kevin-Wright
twitter: @thecoda
"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
On Thu, Jun 23, 2011 at 2:33 AM, Josh Suereth <joshua.suereth@gmail.com> wrote:
We wanted to keep to the principle that extractors mirror constructors. Since only list has '::', it made sense to restrict the extractor to lists. One could
think of defining '::' more generally, but then, that would be backwards incompatible, and I do not know what the performance implications for list would be.
Cheers
-- Martin