https://github.com/tpapp/nestedmaps.jl
Map arrays of tuples, namedtuples, arrays etc elementwise.
https://github.com/tpapp/nestedmaps.jl
Last synced: 4 months ago
JSON representation
Map arrays of tuples, namedtuples, arrays etc elementwise.
- Host: GitHub
- URL: https://github.com/tpapp/nestedmaps.jl
- Owner: tpapp
- License: other
- Created: 2018-12-30T13:53:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-20T09:17:09.000Z (over 5 years ago)
- Last Synced: 2026-01-20T20:05:03.944Z (5 months ago)
- Language: Julia
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# NestedMaps

[](https://travis-ci.com/tpapp/NestedMaps.jl)
[](http://codecov.io/github/tpapp/NestedMaps.jl?branch=master)
Julia package for mapping nested collections elementwise.
Not yet registered, install from repository.
```julia
julia> using NestedMaps
julia> A = [(a = i, b = (c = -i, d = [i^2, -i^2])) for i in 1:3]
3-element Array{NamedTuple{(:a, :b),Tuple{Int64,NamedTuple{(:c, :d),Tuple{Int64,Array{Int64,1}}}}},1}:
(a = 1, b = (c = -1, d = [1, -1]))
(a = 2, b = (c = -2, d = [4, -4]))
(a = 3, b = (c = -3, d = [9, -9]))
julia> nested_map(identity, A)
(a = [1, 2, 3], b = NamedTuple{(:c, :d),Tuple{Int64,Array{Int64,1}}}[(c = -1, d = [1, -1]), (c = -2, d = [4, -4]), (c = -3, d = [9, -9])])
julia> nested_map_recursive(sum, A)
(a = 6, b = (c = -6, d = [14, -14]))
```