authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2023-07-07 21:52:43+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-12 15:35:57-07:00
log299e86598d554d753efb7d5f1fa093a0d4e81519
tree60d83506109b6c516a8f459e1defbcdf28a3a5ff
parenta0ec2266fe2bd8a986795c6634407a6f7df9a50f

Update langref to new splat syntax


1 files changed, 7 insertions(+), 7 deletions(-)

doc/langref.html.in+7-7
......@@ -9239,10 +9239,10 @@ test "vector @shuffle" {
92399239 {#header_close#}
92409240
92419241 {#header_open|@splat#}
9242 <pre>{#syntax#}@splat(comptime len: u32, scalar: anytype) @Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>
9242 <pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre>
92439243 <p>
9244 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
9245 {#syntax#}scalar{#endsyntax#}:
9244 Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}.
9245 The return type and thus the length of the vector is inferred.
92469246 </p>
92479247 {#code_begin|test|test_splat_builtin#}
92489248const std = @import("std");
......@@ -9250,8 +9250,7 @@ const expect = std.testing.expect;
92509250
92519251test "vector @splat" {
92529252 const scalar: u32 = 5;
9253 const result = @splat(4, scalar);
9254 try comptime expect(@TypeOf(result) == @Vector(4, u32));
9253 const result: @Vector(4, u32) = @splat(scalar);
92559254 try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
92569255}
92579256 {#code_end#}
......@@ -9292,8 +9291,9 @@ const std = @import("std");
92929291const expect = std.testing.expect;
92939292
92949293test "vector @reduce" {
9295 const value = @Vector(4, i32){ 1, -1, 1, -1 };
9296 const result = value > @splat(4, @as(i32, 0));
9294 const V = @Vector(4, i32);
9295 const value = V{ 1, -1, 1, -1 };
9296 const result = value > @as(V, @splat(0));
92979297 // result is { true, false, true, false };
92989298 try comptime expect(@TypeOf(result) == @Vector(4, bool));
92999299 const is_all_true = @reduce(.And, result);