52
kookoon
6y

My main problem while learning new programming languages

Comments
  • 3
    naming things happens to be the most difficult things to do in programming
  • 2
    also, length should make you think that array is one dimension only. While size, well this could be n-dimensional
  • 5
    I see you have not yet encountered Lua...
    #array -- yes, this returns the length, however do NOT call it on non-sequences as the result is undefined in that case and can be any number or reference (u0b34a0f6ae for Lua 5.1, cubuspl42 for Lua 5.2 and so on...)
  • 0
    @bytecode for _,__ in pairs(list) do count = count + 1 end
  • 2
    @deviloper Naming things, cache invalidation and off by 1 errors are the two most difficult problems :-)
  • 0
    @muttley you mentioned actually 3 problems. Oh. I see. sorry :-)
  • 1
    @AlgoRythm yes... but # is the ".length()" in Lua
  • 0
    @bytecode Not before Lua 5

    Or some recent version. Maybe even 5.2.
  • 2
    There’s also .count, .count(), and len(arr)
  • 1
    The rust function naming conventions have changed my way of thinking about what a function does e.g to_string does a lot of work but as_string is light.

    To me:
    Length = 1-dimensional
    Size = n-dimensiomal
    Count = doesn't keep track of its size as it grows and has to compute its size
  • 0
    @AlgoRythm hm... I used it when the ComputerCraft mod for Minecraft first came out... that was, 2010/2011 I think ¯\_(ツ)_/¯
  • 0
    Unless you are talking in Python. In which case it is
    Len(Array)
  • 0
    we use commas between tags here fyi

    also "len(array)" best length func
Add Comment