Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^4: 99 Problems in Perl6

by gaal (Parson)
on Dec 15, 2006 at 22:39 UTC ( #590138=note: print w/replies, xml ) Need Help??

in reply to Re^3: 99 Problems in Perl6
in thread 99 Problems in Perl6

Your Haskell compress unfortunately bottoms out on empty input. It's otherwise much better than the stateful Perl 6 version.

Replies are listed 'Best First'.
Re^5: 99 Problems in Perl6
by Ovid (Cardinal) on Dec 15, 2006 at 22:44 UTC

    Lest anyone think I'm a genius, I stole the Haskell code from here.


    New address of my CGI Course.

      The "alternative solution" posted there doesn't suffer from the monomorphism restriction*, and thus does less to propagate the myth that one has to be a genius to write code in Haskell. It also works correctly with empty input :-)

      compress [] = [] compress [a] = [a] -- singleton list compress (x:y:xs) = (if x == y then [] else [x]) ++ compress (y:xs)
      *Something that, for the casual programmer, is quite technical but uninteresting, has a scary name, and a not-that-friendly error message.
        And indeed, you can do that in Perl too:
        multi compress () { () } multi compress ($a) { item $a } multi compress ($x, $y, *@xs) { $x xx ($x !=== $y), compress($y, |@xs) + } my @x = <a a a a b c c a a d e e e e>; say perl compress |@x;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590138]
[Corion]: ... don't support server-side precompilation (which means the client has to compile all templates to Javascript themselves), or are giant frameworks that expect to do everything (which is not what I want)
[Corion]: I feel that there is a talk somewhere in there, either about the structure and parts, or how I used several parts to get a complete whole.
[Corion]: Maybe I can still find something that is compatible with handlebars.js (which has JS precompilation) but allows for two-way data binding (which is great for the UI)
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2017-03-30 07:52 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (355 votes). Check out past polls.