mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2026-02-19 05:27:03 +01:00
Removed executable module
This commit is contained in:
parent
11b1678e0e
commit
6e870b9f8b
2 changed files with 0 additions and 162 deletions
25
src/main.zig
25
src/main.zig
|
|
@ -1,25 +0,0 @@
|
|||
const std = @import("std");
|
||||
const iter = @import("iterating").Iter;
|
||||
|
||||
pub fn main() !void {
|
||||
const arith = struct {
|
||||
fn square(x: i32) i32 {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
fn is_square(x: i32) bool {
|
||||
const sqrt = @sqrt(@as(f32, @floatFromInt(x)));
|
||||
return sqrt == @floor(sqrt);
|
||||
}
|
||||
|
||||
fn try_sqrt(x: i32) ?i32 {
|
||||
const sqrt = @sqrt(@as(f32, @floatFromInt(x)));
|
||||
return if (sqrt == @floor(sqrt)) @intFromFloat(sqrt) else null;
|
||||
}
|
||||
};
|
||||
|
||||
const items = try iter(i32).once(-100).chain(iter(i32).rangeInclusive(1, 100).filter(arith.is_square).chain(iter(i32).range(0, 10))).toOwnedSlice(std.heap.page_allocator);
|
||||
defer std.heap.page_allocator.free(items);
|
||||
|
||||
std.debug.print("{any}\n", .{items});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue