Hello,
On Fri, Nov 30, 2012 at 11:05 AM, Daniel Sobral <dcso...@gmail.com> wrote:
> I just want to make a small point here: if you want to sort, why are you
> sticking with quicksort for the functional algorithm? It's not like
> quicksort is the only sorting algorithm, nor even the most efficient one,
> and it's certainly not a good match for Scala FP. By all means, compare an
> imperative quicksort with a functional sorting algorithm if you want, but
> it's pretty damn silly to choose an algorithm that is particularly unsuited
> to strict FP for a benchmark.
>
> As a side note, I hear quicksort with lazy FP is much better, but that's
> hearsay.
Is there any sorting algorithm of order n*log(n) that is suitable
for strict FP?
Take care
Oliver
--
IT Project Lead at PanGenX (http://www.pangenx.com)
"Stagnation and the search for truth are always opposites." - Nadezhda
Tolokonnikova
OP: Here's a link to a video of Martin Odersky saying FP is better.
Practically, maintaining mutable code is like managing your memory manually.
For example, in Haskell, you could use an intermediate STArray. The type system would ensure
that nobody sees the effects from outside the quicksort.
As a side note, I hear quicksort with lazy FP is much better, but that's hearsay.
I believe that in practice the biggest problem in SE is not performance
but maintainability and QA.
OP: Here's a link to a video of Martin Odersky saying FP is better.
For example, in Haskell, you could use an intermediate STArray. The type system would ensure
that nobody sees the effects from outside the quicksort.
This is interesting and in general a good idea for a language to have whether it is made for FP or not. One problem I have with cloning the list and then changing the clone is that the clone process is not thread-safe. I could put a mutex block in the list clone method, but if you put a mutex block around everything like that you might slow down the system.
Well, the OOP variant is to have a class SortedCollection (as in Smalltalk). Whenever an element is added to it, it is moved to the right position so that the SortedCollection remains sorted. Because Java has this Array.sort(...) method and no SortedCollection (TreeSet is sorted, but people simply mostly do Array.sort, because they don't get educated about it). Problem with this is that the SortedCollection is not immutable in that sense.As a side note, I hear quicksort with lazy FP is much better, but that's hearsay.
Saw today some Scala code I wanted to share:
trait GenericFunctor[->>[_, _], ->>>[_, _], F[_]] {
def fmap[A, B](f: A ->> B): F[A] ->>> F[B]
}
Whenever I'm just saying to myself that I should give Scala a try now I see code like that and I just ask myself what the heck is this.
Saw today some Scala code I wanted to share:
trait GenericFunctor[->>[_, _], ->>>[_, _], F[_]] {
def fmap[A, B](f: A ->> B): F[A] ->>> F[B]
}
> -----Ursprüngliche Nachricht-----
> Im Auftrag von Vlad Patryshev
>> Saw today some Scala code I wanted to share:
> >
> > trait GenericFunctor[->>[_, _], ->>>[_, _], F[_]] {
> > def fmap[A, B](f: A ->> B): F[A] ->>> F[B]
> > }
>
> This is pretty funny. Two categories have the same collection of objects
> (arbitrary A and B), but different collections of morphisms.
>
> What is it good for, I wonder. Hope there is some kind of science there, not
> just c++ programmers going rogue.
I suppose it comes from:
https://hseeberger.wordpress.com/2010/11/25/introduction-to-category-theory-in-scala/
My spontaneous reaction to Oliver's conclusion on this code:
> Whenever I'm just saying to myself that I should give Scala a try now I see
> code like that and I just ask myself what the heck is this.
I am interested in science, and physics seems to be something one should
know a bit about. But every time I want to give it a try I see things like this:
http://en.wikipedia.org/wiki/Quantum_phase_estimation_algorithm#The_Algorithm
Or I open a popscience magazine and see things like this:
http://blog.streitenberger.net/wp-content/uploads/png/360GradPanoramasdesLHCamCERN_8BE2/lhc.jpg
No, seriously. Code like the one above is fascinating and scaring at the same time.
But it is not where to start from, this is where possibly(but not necessarily!) one day to land.
And this is presumably one of the best features of Scala and its community: It teaches you
new mind broadening things and makes you think differently. Step by step.
KR
Det
BITMARCK Software GmbH
Firmensitz: Paul-Klinger-Strasse 15, 45127 Essen
Geschaeftsfuehrer: Andreas Strausfeld
Registergericht: Amtsgericht Essen HRB 20680
***********************************************************************
Die Information in dieser E-Mail ist vertraulich und ist ausschliesslich
fuer den/die benannten Adressaten bestimmt. Ein Zugriff auf diese
E-Mail durch andere Personen als den/die benannten Adressaten ist
nicht gestattet. Sollten Sie nicht der benannte Adressat sein, loeschen
Sie bitte diese E-Mail.
> case class Marriage(spouse1: Person, spouse2: Person)But how does a person know which marriage they are part of?
> Thereby removing the circularity.
But you fail the requirements. If I pass you the object sally, how
can you find out who she's married to?