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

Pages: 1-

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 14:15

while n~=0 do table.insert(t,n) end

Is n ever decremented?

Name: Anonymous 2007-11-19 14:18

Well, what the fuck did you expect? It reads a nonzero digit and starts inserting it like hell.

FUCKING MORON. FUCK.

Name: Anonymous 2007-11-19 15:01

NOW THAT'S A REALLY FUCKING ODD BUG, YOU FAGGOT

Name: Anonymous 2007-11-19 15:30

>>1 should've used Haskell.

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?

Name: Anonymous 2007-11-19 16:18

>>6
(a -> Bool)       -> [a]        -> Maybe a
boolean predicate    list of as    single value a (if any)


What the fuck you don't understand?

Name: Anonymous 2007-11-19 16:23

Oh, I see. You think the boolean predicate should take a list of as. When exactly should it return True, then?

Name: Anonymous 2007-11-19 16:23

Oh, I see. You think the boolean predicate should take a list of as. When exactly should it return True, then?

Name: Anonymous 2007-11-19 16:25

>>6
Here, let me make it simpler for your simian brain:
findElement p = listToMaybe . filter p

Name: Anonymous 2007-11-19 16:29

STFU about boolean predicates and shit bunch of assfagots

Name: Anonymous 2007-11-19 16:35

>>11
The OMG OPTIMIZED kid is angry because we use big words he doesn't understand.

Name: 6 2007-11-19 16:41

>>7-12
YHBT YHL HAND ^_^

Name: Anonymous 2007-11-19 16:50

>>13
Omg wtf (ò_ó) UH UH BAKA NEKO THAT’S BULLSHITE!! We r expart programmers here =^____^= haskell ftw!!!!!!! ** (*O*)/ I loooev abstrect concepts (^________<) ^_________________^;;;;;;;;;;;;;;;;

Name: Anonymous 2007-11-19 16:58

>>6
In the Haskell type system, (->) is an operator that takes two types and creates a function. It is right associative. With this knowledge, you can deconstruct the type (a -> Bool) -> [a] -> Maybe a. Taking associativity into account this is:
(a -> Bool) -> ([a] -> Maybe a)[code]
So this function takes a function from [code]a
to Bool, and returns a function from [a] to Maybe a. By uncurrying, we can see that this is raelly a function that takes two arguments -- a function from a to Bool, and [a]. The return value is Maybe a.

Name: Anonymous 2007-11-19 17:52

>>10
Here, let me make it simpler for your simian brain:
findElement = listToMaybe . filter

Name: Anonymous 2007-11-19 19:01

>>16 doesn't understand point free.

Name: Anonymous 2007-11-19 22:09

>>16
Here, let me make it simpler for your simian brain:
findElement = listToMaybe `dot` filter

Name: Anonymous 2007-11-19 22:14

>>2
>>3
>>4
maybe table.insert(t,n) was supposed to decrement the shit?

Name: Anonymous 2007-11-19 22:17

WORD TO THE WISE, IF ANYONE STARTS A POST WITH "In the Haskell type system" IGNORE THEM!!!!!!!!!!!!!!!!!!!!!

Name: Anonymous 2007-11-20 3:41

>>19
Maybe not.

Name: Anonymous 2007-11-20 7:45

>>18
I tend to use the name (.:) instead of dot, and (.::) when the second function takes three arguments, and so on... Am I a faggot?

Name: Anonymous 2007-11-20 7:47

>>22
no, actually it seems a pretty nice convention. I don't really like `dot`

Name: Anonymous 2007-11-20 8:10

How did this thread get hijacked by the OMG OPTIMIZED kid and the haskellFag?

Name: Anonymous 2007-11-20 13:43

In the Haskell type system we do things differently.

Name: Anonymous 2007-11-20 15:53

>>20
In the Haskell type system, you're a fag

Name: Anonymous 2007-11-20 16:28

function blue_water()
{
   while(1) // a loop that is always true
   {
      if (fox.position == in_blue_water) // if the fox is in the blue water
      {
         fox.health = 0; // the fox dies as it's health is being set to 0
      }
     
      if (fox.position != in_blue_water) // if the fox is not in the blue water
      {
         fox.wants_to_get_wet = true; // flag being set to true to make the fox want to get wet
      }
     
      wait(1); // process once each game frame
   }
}

Name: Anonymous 2007-11-20 16:32

>>24
This is /prog/.

Name: Anonymous 2007-11-20 16:33

Does anyone have a good keymap for Haskell?  I don't really want to enter U+123123 when I just want to type alpha.

Name: Anonymous 2007-11-20 17:01

>>29
i need lambda

Name: Anonymous 2007-11-20 17:08

>>27
Goldmine of lulz where that came from: http://www.ulillillia.us/aboutme/majorfears.shtml

Name: !MhMRSATORI 2007-11-20 17:10

>>31
I can use Google.

Go die in the blue water.

Name: Anonymous 2007-11-20 17:44

>>32
That post was made to alert my fellow 4channers that there was something to be gained by finding where that code snippet comes from, and in addition to give a direct link for their convenience.

It was not made to show off my "google-fu" (of which indeed little is needed for this task), so your summary of my post is incorrect. Therefore I feel that your outrage is uncalled for, and hope to recieve your apologies forthwith.

Sincerely,

Anonymous

Name: 32 2007-11-20 18:19

>>33
Sorry, sir.

Name: Anonymous 2007-11-21 5:37

>>33
>>34
same person

Name: Anonymous 2007-11-21 5:56

>>33
yes but the guy said "go die in the blue water". the joke is the "blue water".

Name: Anonymous 2007-11-22 9:22

>>17
You mean point less?

Name: Anonymous 2009-03-06 10:34

Still smaller than a   keyboard would be   melding mellifond indo.

Name: Anonymous 2010-11-27 9:35

Name: Anonymous 2010-12-20 17:25


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