Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New recipes from other awesome cookbook #44

Closed
jiacai2050 opened this issue Jan 15, 2024 · 4 comments
Closed

New recipes from other awesome cookbook #44

jiacai2050 opened this issue Jan 15, 2024 · 4 comments

Comments

@jiacai2050
Copy link
Member

jiacai2050 commented Jan 15, 2024

Some examples I find:

@horochx
Copy link

horochx commented Jan 15, 2024

I will add an example in 15. Text Processing similar to the Turning an Array into a Sentence and Processing a String One Word or Character at a Time in the Go Cookbook.

@jiacai2050
Copy link
Member Author

jiacai2050 commented Jan 15, 2024

@horochx Those two example seems too simple for me, I don't know if it's necessary to add them.

@rakshasha-medhi
Copy link

@jiacai2050 I'm currently learning Zig and I got quite a collection of Zig code snippets...however how to know if something is too simple? I mean I've been struggling to find reference to learn Zig, hence I made the snippet collection...and I think this Zig cookbook is gonna be amazingly helpful for Zig newcomers.

For example i see there's Generate Random Numbers in the cookbook already, but it's using crypto.random. I have snippet that uses rand.DefaultPrng:

const RndGen = std.rand.DefaultPrng;
const tMilli = std.time.milliTimestamp;
const PageAlloc = std.heap.page_allocator;

fn gen_randNum(minVal: u32, maxVal: u32, arraySize: u32) ![]u32 {
    var seed = tMilli();
    var rnd = RndGen.init(@intCast(seed));
    var randNums = try PageAlloc.alloc(u32, arraySize);

    for (randNums) |*num| {
        num.* = rnd.random().intRangeAtMost(u32, minVal, maxVal);
    }
    return randNums;
}

I also got plenty of Sorting and Search Algorithms written in Zig.

To be honest I have been looking for an avenue to contribute to Zig learning for newcomers...so I would love to be involved in the Zig Cookbook. Cheers!

@jiacai2050
Copy link
Member Author

but it's using crypto.random. I have snippet that uses rand.DefaultPrng

I don't see much difference between those, so I would suggest you try another recipe, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants