Skip to main content
Make Legal
Source Link

Zig, 63 66 4747 72 bytes

fn a()void{for(" "**'e')|_,i|{p@import("std").debug.print("{d} ",.{i});}}

Try it online!Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p@import("std").debug.print("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • p@import("std").debug.print("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • p("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.

Zig, 63 66 47 72 bytes

fn a()void{for(" "**'e')|_,i|{@import("std").debug.print("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

fn a() void {
    for (" " ** 'e') |_, i| {
        @import("std").debug.print("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • @import("std").debug.print("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.
Extra Explanation
Source Link

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • p("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • p("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.
Add explanation
Source Link

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Zig, 63 66 47 bytes

fn a()void{for(" "**'e')|_,i|{p("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

const p = @import("std").debug.print; // Import the debugging print function

fn a() void {
    for (" " ** 'e') |_, i| {
        p("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
Use a for loop with a dirty slice hack
Source Link
Loading
u8 -> c_int
Source Link
Loading
Source Link
Loading