• Destide ( sirico@feddit.uk ) OP
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 year ago

    As we’re posting examples I’ll add how lovely it is in Elixir. Elixir def not putting the fun in programmer memes do. One reason I picked it because I can’t be trusted to not be the meme.

    def is_even?(n) do
      rem(n, 2) == 0
    end
    
    • balsoft ( balsoft@lemmy.ml ) 
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      I mean, it would be almost this exact thing in almost any language.

      fn is_even(n: i64) -> bool {
          n % 2 == 0
      }
      
      even n = n `rem` 2 == 0
      
      def is_even(n):
          return n % 2 == 0
      

      etc