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" {...@@ -9239,10 +9239,10 @@ test "vector @shuffle" {
9239 {#header_close#}9239 {#header_close#}
92409240
9241 {#header_open|@splat#}9241 {#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>
9243 <p>9243 <p>
9244 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value9244 Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}.
9245 {#syntax#}scalar{#endsyntax#}:9245 The return type and thus the length of the vector is inferred.
9246 </p>9246 </p>
9247 {#code_begin|test|test_splat_builtin#}9247 {#code_begin|test|test_splat_builtin#}
9248const std = @import("std");9248const std = @import("std");
...@@ -9250,8 +9250,7 @@ const expect = std.testing.expect;...@@ -9250,8 +9250,7 @@ const expect = std.testing.expect;
92509250
9251test "vector @splat" {9251test "vector @splat" {
9252 const scalar: u32 = 5;9252 const scalar: u32 = 5;
9253 const result = @splat(4, scalar);9253 const result: @Vector(4, u32) = @splat(scalar);
9254 try comptime expect(@TypeOf(result) == @Vector(4, u32));
9255 try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));9254 try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
9256}9255}
9257 {#code_end#}9256 {#code_end#}
...@@ -9292,8 +9291,9 @@ const std = @import("std");...@@ -9292,8 +9291,9 @@ const std = @import("std");
9292const expect = std.testing.expect;9291const expect = std.testing.expect;
92939292
9294test "vector @reduce" {9293test "vector @reduce" {
9295 const value = @Vector(4, i32){ 1, -1, 1, -1 };9294 const V = @Vector(4, i32);
9296 const result = value > @splat(4, @as(i32, 0));9295 const value = V{ 1, -1, 1, -1 };
9296 const result = value > @as(V, @splat(0));
9297 // result is { true, false, true, false };9297 // result is { true, false, true, false };
9298 try comptime expect(@TypeOf(result) == @Vector(4, bool));9298 try comptime expect(@TypeOf(result) == @Vector(4, bool));
9299 const is_all_true = @reduce(.And, result);9299 const is_all_true = @reduce(.And, result);