Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import "os" for Platform, Process
|
||||
import "io" for File
|
||||
import "meta" for Meta
|
||||
import "/pattern" for Pattern
|
||||
import "/math" for Nums
|
||||
import "./pattern" for Pattern
|
||||
import "./math" for Nums
|
||||
|
||||
var a = 4 /* 1st integer variable */
|
||||
var b = 0xA /* 2nd integer variable */
|
||||
|
|
@ -13,7 +13,7 @@ var bloop = -17.3
|
|||
var checkVersion = Fn.new {
|
||||
var version = Process.version
|
||||
var components = version.split(".")
|
||||
if (Num.fromString(components[1]) < 3) {
|
||||
if (Num.fromString(components[1]) < 4) {
|
||||
Fiber.abort("Wren version (%(version)) is too old.")
|
||||
}
|
||||
}
|
||||
|
|
@ -43,4 +43,4 @@ Meta.eval("d = bloop.abs") // this won't compile if either 'bloop' or 'abs' not
|
|||
System.print("bloop.abs = %(d)")
|
||||
var vars = res[0]
|
||||
var vals = res[1]
|
||||
System.print("The sum of the %(vars.count) integer variables, %(vars), is %(Nums.sum(vals))"
|
||||
System.print("The sum of the %(vars.count) integer variables, %(vars), is %(Nums.sum(vals))")
|
||||
|
|
|
|||
23
Task/Introspection/Zig/introspection-1.zig
Normal file
23
Task/Introspection/Zig/introspection-1.zig
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const bloop: i32 = -1_000;
|
||||
|
||||
pub fn abs(a: i32) i32 {
|
||||
return if (a < 0) -a else a;
|
||||
}
|
||||
|
||||
pub fn main() error{NotSupported}!void {
|
||||
if (builtin.zig_version.order(.{ .major = 0, .minor = 11, .patch = 0 }) == .lt) {
|
||||
std.debug.print("Version {any} is less than 0.11.0, not suitable, exiting!\n", .{builtin.zig_version});
|
||||
return error.NotSupported;
|
||||
} else {
|
||||
std.debug.print("Version {any} is more or equal than 0.11.0, suitable, continuing!\n", .{builtin.zig_version});
|
||||
}
|
||||
|
||||
if (@hasDecl(@This(), "bloop") and @hasDecl(@This(), "abs")) {
|
||||
std.debug.print("abs(bloop) = {d}\n", .{abs(bloop)});
|
||||
} else {
|
||||
std.debug.print("abs and/or bloop are not defined!\n", .{});
|
||||
}
|
||||
}
|
||||
25
Task/Introspection/Zig/introspection-2.zig
Normal file
25
Task/Introspection/Zig/introspection-2.zig
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub const first_integer_constant: i32 = 5;
|
||||
pub const second_integer_constant: i32 = 3;
|
||||
pub const third_integer_constant: i32 = -2;
|
||||
|
||||
pub const some_non_integer_constant: f32 = 0.0;
|
||||
pub const another_non_integer_constant: bool = false;
|
||||
|
||||
pub fn main() void {
|
||||
comptime var cnt: comptime_int = 0;
|
||||
comptime var sum: comptime_int = 0;
|
||||
inline for (@typeInfo(@This()).Struct.decls) |decl_info| {
|
||||
const decl = @field(@This(), decl_info.name);
|
||||
switch (@typeInfo(@TypeOf(decl))) {
|
||||
.Int, .ComptimeInt => {
|
||||
sum += decl;
|
||||
cnt += 1;
|
||||
},
|
||||
else => continue,
|
||||
}
|
||||
}
|
||||
|
||||
@compileLog(std.fmt.comptimePrint("cnt = {d}, sum = {d}", .{ cnt, sum }));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue