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

rate my code prog?

Name: Anonymous 2011-09-24 11:08

rate my code prog?



function nfa:translate_state_numbers(offset)
  self.transition_table = t.remap(self.transition_table,
                                  function(i,transitions)
                                    return i + offset
                                  end,
                                  function(i,transitions)
                                    return t.map(transitions,
                                                 function(state_set)
                                                   return t.map_keys(state_set,
                                                                     function(state_number)
                                                                       return state_number + offset
                                                                     end)
                                                 end)
                                  end)
  self.state_status_table = t.map_keys(self.state_status_table,
                                       function(state_number)
                                         return state_number + offset
                                       end)
  self.start_state = t.map_keys(self.start_state,
                                function(state_number)
                                  return state_number + offset
                                end)
end

Name: Anonymous 2011-09-24 11:18

which is better?



function nfa:translate_state_numbers(offset)
  self.transition_table = t.remap(
    self.transition_table,
    function(i,transitions)      
      return i + offset            
    end,                         
    function(i,transitions)      
      return t.map(
        transitions,
        function(state_set)                     
          return t.map_keys(
            state_set,
            function(state_number)                                  
              return state_number + offset                            
            end)                                                    
        end)
    end)                         
  self.state_status_table = t.map_keys(
    self.state_status_table,
    function(state_number)            
      return state_number + offset      
    end)                              
  self.start_state = t.map_keys(
    self.start_state,
    function(state_number)     
      return state_number + offset
    end)                       
end

Name: Anonymous 2011-09-24 11:49

It's perfect.

Name: Anonymous 2011-09-24 11:53

Unaesthetic as fuck
Bad AB genetics
twig arms
no chest
4/10

Name: Anonymous 2011-09-24 12:37

>>1,2
Ever heard of comments?

Name: Anonymous 2011-09-24 12:45

>>1
looks like Lua. Ugly-ass terrible lua, but lua nonetheless. you can write shit in any language.

Name: Anonymous 2011-09-24 13:49

>>5

Many job interviews require a candidate to read uncommented code, and describe what it does. Thus, one who needs comments to read my code is an inadequate candidate for a job in programming.

Name: Anonymous 2011-09-24 13:53

not python, not relevant

Name: Anonymous 2011-09-24 13:58

>>8

well, it's almost python. Lua is like python with its limbs chopped off.

Name: Anonymous 2011-09-24 14:01

>>9
and lua is slow as fuck compared to python

every time i see a game use lua for scripting i feel the urge to import facepalm

Name: Anonymous 2011-09-24 14:10

>>10

It's not nice to call a quadriplegic slow. It's not Lua's fault.

Name: Anonymous 2011-09-24 14:20

>>8,10 here
looking at the code again... anonymous functions??? what the fuck??? name those fucking things.

Name: Anonymous 2011-09-24 14:21

>>10

actually,


#!/usr/bin/python

for i in range(10000000): pass


runs much slower than


#!/usr/bin/lua

for i=1,10000000 do
end


and the python version seems to use my hard drive for some reason. Therefore, your argument is invalid and Lua is faster than python.

Name: Anonymous 2011-09-24 14:24

>>13
use xrange faggot

Name: Anonymous 2011-09-24 14:30

>>12


(function(self) self(self, 'How about:') end)(function(self, message) print(message); self(self, message .. ' no ' .. message) end)

Name: Anonymous 2011-09-24 14:45

>>14

thanks for the tip, but after making the change, lua is still fasta:


lua-fan@luaisdabest>>cat loop.lua
#!/usr/bin/lua

for i=1,10000000 do
end
lua-fan@luaisdabest>>cat loop.py
#!/usr/bin/python

for i in xrange(10000000): pass
lua-fan@luaisdabest>>time loop.lua

real    0m0.877s
user    0m0.852s
sys     0m0.004s
lua-fan@luaisdabest>>time loop.py

real    0m6.677s
user    0m6.616s
sys     0m0.036s
lua-fan@luaisdabest>>scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
(define lua_times '(.877 .852 .004))
#<unspecified>
(define python_times '(6.677 6.616 .036))
#<unspecified>
(define lua-is-better (map / python_times lua_times))
#<unspecified>
lua-is-better
(7.6134549600912215 7.765258215962441 9.0)
`(python uses ,(car lua-is-better) times more real "time,"
              ,(cadr lua-is-better) times more user "time,"
          and ,(caddr lua-is-better) times more system "time!")
(python uses 7.6134549600912215 times more real "time," 7.765258215962441 times more user "time," and 9.0 times more system "time!")

Name: Anonymous 2011-09-24 14:48

>>16
Why are you running lua interpreted?  Just load it in the JIT and eviscerate him.

Name: Anonymous 2011-09-24 15:03

>>17

I don't have it at the moment, unfortunately. Also to benchmark luajit against python, you would have to use some kind of jit for python, or compile it to C or something.

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