From 07786c47515d30e747ba24c390aa54ce9d22e2f0 Mon Sep 17 00:00:00 2001 From: Tarik Hijstek Date: Tue, 18 Oct 2022 19:25:06 +0200 Subject: [PATCH] comments --- src/main.zig | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main.zig b/src/main.zig index 83b6c51..08ee641 100644 --- a/src/main.zig +++ b/src/main.zig @@ -99,16 +99,16 @@ pub fn rule1Test(input: []Symbol ) bool{ } pub fn rule1(input: []Symbol) ![]Symbol{ - std.debug.print("Rule1\n", .{}); + // Ends on I? Add U. + // Allocate space for new array var arr = try std.heap.page_allocator.alloc(Symbol, input.len + 1); - + //copy input into the allocated array - // Assignment doesn't work, that also changes the length of the destination. + //NOTE: Assignment doesn't work, that also changes the length of the destination. mem.copy(Symbol, arr, input[0..]); arr[arr.len-1] = Symbol.U; - - std.debug.print("Rule1 result: {any}\n", .{arr}); + return arr; } @@ -117,19 +117,7 @@ pub fn rule2Test(input: []Symbol) bool { } pub fn rule2(input: []Symbol) ![]Symbol{ //M_ => M__ - - std.debug.print("Rule2\n", .{}); - - // var arr = try std.heap.page_allocator.alloc(Symbol, input.len * 2); - - // arr = input[0..]; - // arr[input.len] = input[1..]; - - // mem.copy([]Symbol, arr) - const arr = mem.concat(std.heap.page_allocator, Symbol, &[_][]Symbol{input[0..], input[1..]}); - std.debug.print("Rule2 result: {any}\n", .{arr}); - return arr; }