Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Weird Lua bug(?)

Name: Anonymous 2007-11-19 14:12

Was attempting to write an ETHIOPIAN NIGGER-SCALE SOLUTION to the problem posed by the OP of this thread: http://dis.4chan.org/read/prog/1195330684/ when I ran into a really odd bug:
n,t=io.read("*number"),{}
while n~=0 do table.insert(t,n) end
for i,v in ipairs(t) do print(i,v) end


Run this code, it will prompt you for a number, enter one and hit return: it will eat as much memory and CPU cycles as possible.

What the shit?

Name: Anonymous 2007-11-19 16:11

>>5
Since you seem like an expertHaskellProgrammer to me, please explain the datatype stuff to me, I really don't get it.


Like here:

findElement :: (a -> Bool) -> [a] -> Maybe a
findElement p [] = Nothing
findElement p (x:xs) =
    if p x then Just x
    else findElement p xs


Explain (a -> Bool) -> [a] -> Maybe a to me. I think that it should take a list of as and a boolean predicate and return a single value a, so [code]([a] -> Bool) -> Maybe a[code]. Why am I wrong?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List