Skip to content

Commit 7cb120a

Browse files
DilumAluthgepiever
andauthored
README: Document how to delete a row (#146)
* Document how to delete a row * Update README.md Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com> Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>
1 parent 5d2be9e commit 7cb120a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,31 @@ blocks = cld(length(dd),threads)
275275

276276
@cuda threads=threads blocks=blocks kernel!(de, dd)
277277
```
278+
279+
## Applying a function on each field array
280+
281+
```julia
282+
julia> struct Foo
283+
a::Int
284+
b::String
285+
end
286+
287+
julia> s = StructArray([Foo(11, "a"), Foo(22, "b"), Foo(33, "c"), Foo(44, "d"), Foo(55, "e")]);
288+
289+
julia> s
290+
5-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype Foo:
291+
Foo(11, "a")
292+
Foo(22, "b")
293+
Foo(33, "c")
294+
Foo(44, "d")
295+
Foo(55, "e")
296+
297+
julia> StructArrays.foreachfield(v -> deleteat!(v, 3), s)
298+
299+
julia> s
300+
4-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype Foo:
301+
Foo(11, "a")
302+
Foo(22, "b")
303+
Foo(44, "d")
304+
Foo(55, "e")
305+
```

0 commit comments

Comments
 (0)