Skip to main content
Glama

Zignet

by fulgidus
Do What The F*ck You Want To Public License
advanced-test-mistral-2025-10-26T02-53-34-678Z.md3.75 kB
# Advanced Zig Test Report **Model**: mistral **Date**: 2025-10-26T02:53:34.678Z **Total Tests**: 6 **Passed**: 6 **Failed**: 0 **Average Response Time**: 82.73s ## Results ### 1. Basic Zig Syntax [EASY] **Status**: ✅ PASS **Time**: 39.24s **Response**: ```zig Here's a simple Zig function in Zig language that returns the sum of two integers: ```zig const std = @import("std"); pub fn main(args: []const char; env: *const std.Env) !void { const int a = 5; const int b = 3; const int sum = .{sum}(a, b); std.io.putstr("The sum of ", a, " and ", b, " is: ", sum, "\n"); } pub fn sum(left: int, right: int) int { return left + right; } ``` This code defines a `sum` function that takes two integer arguments and returns their sum. The ma ``` ### 2. Memory Allocation [EASY] **Status**: ✅ PASS **Time**: 108.25s **Response**: ```zig In Zig, you can create your own simple allocator and manage memory allocation for a custom structure. Here's a basic example of an allocator for an `UntypedStruct` containing an `i32` (integer) field and functions to allocate, access, and free the allocated memory. ```zig const std = @import("std"); pub struct UntypedStruct { data: *u8, size: u32, } const allocatorSize(struct: type[*UntypedStruct]) = struct.FieldSizeof!(); fn allocateUntypedStruct() *UntypedStruct { var memory = ``` ### 3. Error Handling [MEDIUM] **Status**: ✅ PASS **Time**: 85.97s **Response**: ```zig In Zig, I'll show you an example of a simple function that uses the `Result` type to return either a success value or an error. The example demonstrates error handling in the caller as well. First, let's define our custom error type and error functions: ```zig const std = @import("std"); const Result = import("result"); pub const Error = enum { Success, Failure(i32), // Custom error message }; pub fn error(message: zigstr)!Error { return .Failure(std.fmt.Sprint(message)); } ``` ``` ### 4. Structs & Methods [MEDIUM] **Status**: ✅ PASS **Time**: 103.10s **Response**: ```zig In Zig language, here is a simple implementation of a `Point` struct with `x` and `y` coordinates and a method (or function) to calculate the distance from the origin: ```zig const std = @import("std"); pub const Point = struct { x: f64, y: f64, }; pub fn distanceFromOrigin(point: Point) f64 { return sqrt(point.x * point.x + point.y * point.y); } ``` You can use the `Point` struct and `distanceFromOrigin` function like this: ```zig const pt = Point{ .x = 3, .y = 4 }; const dist ``` ### 5. Generics [HARD] **Status**: ✅ PASS **Time**: 88.35s **Response**: ```zig In Zig, you can create a generic function to find the maximum of two values using templates. Here's an example implementation for numeric types: ```zig const std = @import("std"); pub fn maxOfTwo(a: T, b: T) !T { if (a > b) { return a; } return b; } pub const fn isNumericType!(ty: anytype) !bool { try std.stdio.writeln("Checking type {}...", .{ty}); var _ = typeof(ty); if (typeof(ty) & ZIG_TYPEOF_INT == ZIG_TYPEOF_INT || typeof(ty) & ZIG_TYPEOF_UINT == ``` ### 6. Comptime Magic [HARD] **Status**: ✅ PASS **Time**: 71.44s **Response**: ```zig To compute a factorial at compile-time using Comptime in Zig, you can create a function that takes an integer as input and returns its factorial value. Here's an example: ```zig const CompileTime = @import("std/stdio/comptime.zig"); const Std = @import("std"); pub fn factorial(n: u64)!comp: comptime(n > 0) -> u64 { if (n == 1) { return 1; } else { return n * factorial(n - 1)!comp; } } fn main() !body { const N = CompileTime.constExpr!(u64, 5); const res = ```

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fulgidus/zignet'

If you have feedback or need assistance with the MCP directory API, please join our Discord server