Ziglings exercises/005_arrays2

Hi There,

A zig noob here. :slight_smile: Trying out ziglings, got this strange error on this exercise

005_arrays2.zig where I used the correct solution of array multiplier operation β€˜**’ but I still get a compilation failure.

Compiling 005_arrays2.zig...
Checking 005_arrays2.zig...
exercises/005_arrays2.zig:29:50: error: binary operator '*' has whitespace on one side, but not the other
    const bit_pattern_unit = [_]u8{ 1, 0, 0, 1 } ** 3;
                                                 ^
Ziglings hint: Fill in the two arrays.
Edit exercises/005_arrays2.zig and run 'zig build' again.
ziglings
└─ run exe elrond failure
error: process exited with code 1
failed command: ./.zig-cache/o/c6ab4a32e0c138451268f23ee5e9fa87/elrond --zig=/home/user/.zvm/master/zig --work-path=exercises --root-path=/home/user/learn/zig/ziglings

Build Summary: 1/3 steps succeeded (1 failed)
ziglings transitive failure
└─ run exe elrond failure

bash-5.1$ 

I am using 0.17.0-dev.1543+6db520a4c version of zig, on a x86_64 linux version 5.15.209, slackware 15.0 distro

Of course I can skip this and move forward, but I thought this is curious at least and I should check with other zig devs.

Hence this post.

Thank you.

I read your link, and I noticed that ziglings never taught the use of **. I don’t know why you would use it. ** has already been removed.

1 Like

Read the next two lines of code after the line you crashed on.

The line with the simd operation is the line that does the repeating.
Problem 2 of the exercise asks you to set the total length of the output pattern on line 32.

The array multiplication is removed from zig. Seems like you found some solution to the old version of the problem.

Comptime array multiplication will be removed in next release 0.17 afaik, use @splat build in if possible, this operator is deprecated, i recommend doing ziglings on stable branch as master branch does do change pretty rapidly, if the correct solution seems to be with this operator, then file an issue to the ziglings exercises

Thank you, Yes I read the ziglings again after your post and of course you are right.
I used the array multiplier approach based on this book.
I did not know about the deprecation of the operator in mainline.

Yes it β€˜clicked’ now. Thank you for taking time to reply/post. Much appreciated.

1 Like