Ok, Lemmy, let's play a game!

Post how many languages in which you can count to ten, including your native language. If you like, provide which languages. I'm going to make a guess; after you've replied, come back and open the spoiler. If I'm right: upvote; if I'm wrong: downvote!

My guess, and my answer...My guess is that it's more than the number of languages you speak, read, and/or write.

Do you feel cheated because I didn't pick a number? Vote how you want to, or don't vote! I'm just interested in the count.

I can count to ten in five languages, but I only speak two. I can read a third, and I once was able to converse in a fourth, but have long since lost that skill. I know only some pick-up/borrow words from the 5th, including counting to 10.

  1. My native language is English
  2. I lived in Germany for a couple of years; because I never took classes, I can't write in German, but I spoke fluently by the time I left.
  3. I studied French in college for three years; I can read French, but I've yet to meet a French person who can understand what I'm trying to say, and I have a hard time comprehending it.
  4. I taught myself Esperanto a couple of decades ago, and used to hang out in Esperanto chat rooms. I haven't kept up.
  5. I can count to ten in Japanese because I took Aikido classes for a decade or so, and my instructor counted out loud in Japanese, and the various movements are numbered.

I can almost count to ten in Spanish, because I grew up in mid-California and there was a lot of Spanish thrown around. But French interferes, and I start in Spanish and find myself switching to French in the middle, so I'm not sure I could really do it.

Bonus question: do you ever do your counting in a non-native language, just to make it more interesting?

you are viewing a single comment's thread
view the rest of the comments
[–] 65 points 1 year ago (4 children)

1. Python

for i in range(11):
    print(i)

2. R

for (i in 0:10) {
  print(i)
}

3. C/C++

#include <iostream>

int main() {
  for (int i = 0; i <= 10; ++i) {
    std::cout << i << std::endl;
  }
  return 0;
}

4. Java

public class CountToTen {
  public static void main(String[] args) {
    for (int i = 0; i <= 10; i++) {
      System.out.println(i);
    }
  }
}

5. Lua

for i = 0, 10 do
  print(i)
end

6. Bash (Shell Script)

for i in $(seq 0 10); do
  echo $i
done

7. Batch (Windows Command Script)

@echo off
for /l %%i in (0,1,10) do (
  echo %%i
)

8. Go

package main

import "fmt"

func main() {
  for i := 0; i <= 10; i++ {
    fmt.Println(i)
  }
}

9. Rust

fn main() {
  for i in 0..=10 {  // 0..=10 includes 10
    println!("{}", i);
  }
}

10. Zig

const std = @import("std");

pub fn main() !void {
    var i: i32 = 0;
    while (i <= 10) {
        std.debug.print("{}\n", .{i});
        i += 1;
    }
}

11. Scala

for (i <- 0 to 10) {
  println(i)
}

12. Fortran

program count_to_ten
  implicit none
  integer :: i

  do i = 0, 10
    print *, i
  end do

end program count_to_ten

13. Haskell

main :: IO ()
main = mapM_ print [0..10]

14. Julia

for i in 0:10
    println(i)
end
  • source
  • hideshow 8 child comments
  • [–] 8 points 1 year ago (2 children)

    If you didn't cheat that's actually pretty impressive.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 4 points 1 year ago (2 children)

    It is astonishingly easy to get basically any LLM to output a simple iteration from one to ten function in all of those languages, and more.

    Here's Assembly:

        newline db 0xA  ; Newline character
    
    section .bss
        number resb 1  ; Reserve a byte for the number
    
    section .text
        global _start
    
    _start:
        mov ecx, 1  ; Start with 1
        mov edx, 10 ; End with 10
    
    loop_start:
        cmp ecx, edx  ; Compare ecx with edx
        jg loop_end   ; If ecx > edx, jump to loop_end
    
        ; Convert number to ASCII
        add ecx, '0'  ; Convert number to ASCII
        mov [number], ecx  ; Store the ASCII value in number
    
        ; Print the number
        mov eax, 4        ; sys_write system call
        mov ebx, 1        ; File descriptor 1 is stdout
        mov ecx, number   ; Pointer to the number
        mov edx, 1        ; Number of bytes to write
        int 0x80          ; Call kernel
    
        ; Print newline
        mov eax, 4        ; sys_write system call
        mov ebx, 1        ; File descriptor 1 is stdout
        mov ecx, newline  ; Pointer to the newline character
        mov edx, 1        ; Number of bytes to write
        int 0x80          ; Call kernel
    
        sub ecx, '0'  ; Convert ASCII back to number
        inc ecx        ; Increment the number
        jmp loop_start  ; Jump back to the start of the loop
    
    loop_end:
        ; Exit the program
        mov eax, 1        ; sys_exit system call
        xor ebx, ebx      ; Exit code 0
        int 0x80          ; Call kernel
    

    Here's FORTRAN

    program iterate_from_one_to_ten
        implicit none
        integer :: i
    
        ! Loop from 1 to 10
        do i = 1, 10
            print *, i
        end do
    end program iterate_from_one_to_ten
    

    Here's COBOL

    PROGRAM-ID. IterateFromOneToTen.
    
    ENVIRONMENT DIVISION.
    
    DATA DIVISION.
    WORKING-STORAGE SECTION.
        01  WS-Counter PIC 9(2) VALUE 1.
    
    PROCEDURE DIVISION.
        PERFORM VARYING WS-Counter FROM 1 BY 1 UNTIL WS-Counter > 10
            DISPLAY WS-Counter
        END-PERFORM.
    
        STOP RUN.
    
  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 1 year ago* (1 child)

    Why does that assembly code use a global variable for a loop value?? It's also ignoring register conventions (some registers need to be preserved before being modified by a function) which would probably break any codebase you use this in

  • source
  • parent
  • hideshow 2 child comments