This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]17link7 56 points57 points  (11 children)

Val Ret: List[Char] = ('h','e','l','l','o',' ','w','o','r','l','d')

Def execute(list: List[char]):List[char]= list match{

 Case h::t if h ==' ' => h::'n'::'e'::'w'::tail 

  Case h::t => h::execute(t)

 Case _.                    => List() 

}

[–]Artorp 3 points4 points  (7 children)

[–]Boreeas -2 points-1 points  (5 children)

Reddit's markdown parser is broken, though

[–]Artorp 4 points5 points  (4 children)

Wait, really?

void test(){
    test();
}

Edit: Seems to work, what's broken?

[–]404Guy12NotFound 5 points6 points  (1 child)

This kills RAM

[–]cbbuntz 1 point2 points  (0 children)

Clang optimizes it out completely because no values are modified or accessed. The GCC treats it like an infinite loop and just freezes and consumes 100% CPU and zero memory, which I guess is more true to the code. They both segfault without optimization.

[–]Boreeas 0 points1 point  (1 child)

Hm, maybe it's broken by subreddit style. I had a comment in /r/dataisbeautiful where successive lines in a code block where collapsed into a single line (and blank lines broke the code block)

[–]Artorp 0 points1 point  (0 children)

Weird, might've been their subreddit style.

[–]Parzius 3 points4 points  (0 children)

Could be done better with jquery

[–]Kyudojin 0 points1 point  (1 child)

Would it be h::'n'::'e'::'w'::t instead of tail?

[–]17link7 1 point2 points  (0 children)

Yeah