|
@@ -33,25 +33,26 @@
|
|
//
|
|
//
|
|
const print = @import("std").debug.print;
|
|
const print = @import("std").debug.print;
|
|
|
|
|
|
-pub fn main() void {
|
|
|
|
- const langs: [6][]const u8 = .{
|
|
|
|
- "Erlang",
|
|
|
|
- "Algol",
|
|
|
|
- "C",
|
|
|
|
- "OCaml",
|
|
|
|
- "Zig",
|
|
|
|
- "Prolog",
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // Let's find the first language with a three-letter name and
|
|
|
|
- // return it from the for loop.
|
|
|
|
- const current_lang: ?[]const u8 = for (langs) |lang| {
|
|
|
|
- if (lang.len == 3) break lang;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- if (current_lang) |cl| {
|
|
|
|
- print("Current language: {s}\n", .{cl});
|
|
|
|
- } else {
|
|
|
|
- print("Did not find a three-letter language name. :-(\n", .{});
|
|
|
|
- }
|
|
|
|
|
|
+pub fn main() void{
|
|
|
|
+ const langs: [6][]const u8 = .{
|
|
|
|
+ "Erlang",
|
|
|
|
+ "Algol",
|
|
|
|
+ "C",
|
|
|
|
+ "OCaml",
|
|
|
|
+ "Zig",
|
|
|
|
+ "Prolog",
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // Let's find the first language with a three-letter name and
|
|
|
|
+ // return it from the for loop.
|
|
|
|
+ const current_lang: ?[]const u8 = for (langs) |lang|{
|
|
|
|
+ if(lang.len == 3){ break lang; }
|
|
|
|
+ }else null;
|
|
|
|
+
|
|
|
|
+ if(current_lang) |cl|{
|
|
|
|
+ print("Current language: {s}\n", .{cl});
|
|
|
|
+ }else{
|
|
|
|
+ print("Did not find a three-letter language name. :-(\n", .{});
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|