lukstru

joined 10 months ago
[–] lukstru@lemmy.world 1 points 2 days ago* (last edited 2 days ago)

Yes I cheated. To be fair, I used each of those languages at one point and knew how to do it but was to lazy to look it up again.

Edit: except Fortran

[–] lukstru@lemmy.world 1 points 2 days ago

Yes, that was on purpose

[–] lukstru@lemmy.world 65 points 4 days ago (10 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
[–] lukstru@lemmy.world 10 points 2 weeks ago (3 children)

PeerTube isn’t bad, it just has no content

[–] lukstru@lemmy.world 2 points 2 weeks ago

You are completely right

[–] lukstru@lemmy.world 4 points 3 weeks ago (2 children)

I‘d say fatherfucker is still derogatory - after all, it’s still incest. Fatherhugger? Manhugger?

[–] lukstru@lemmy.world 2 points 4 weeks ago

You mean that zeppelin was high in the clouds and motorhead are oil heads?

[–] lukstru@lemmy.world 1 points 1 month ago

I can tell you that Turing is not only celebrated because he was gay. That man is one of the fathers of computer science as we know it today. His Turin machines are the basis for a lot of theoretical computer science

2
Yes (lemmy.world)
 
1
I’m that bench (lemmy.world)
submitted 9 months ago* (last edited 9 months ago) by lukstru@lemmy.world to c/memes@lemmy.ml