# Defining a parameter out of pairs and values

**URL:** https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701
**Category:** General Usage
**Tags:** question, tuple, dictionary, arrays
**Created:** [June 13, 2022, 6:43pm UTC](https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701 "2022-06-13T18:43:22Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)
#### Post date: [June 13, 2022, 8:58pm UTC](https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701/9 "2022-06-13T20:58:03Z")

</div>

> [@noja](#):
>
> [get(d2,only(intersect(get(d1,person,nothing),[pair])),nothing) for person in Persons for pair in pairs]

I’m not sure I understand what the expected result is, but I try

```julia

[(person,pair)=>person_values(person,pair...) for (person,pair) in Iterators.product(Persons,Pairs)][:]

18-element Vector{Pair{Tuple{Char, Tuple{Int64, Int64}}}}:
 ('p', (1, 2)) => 2.5
 ('q', (1, 2)) => 2.5
 ('p', (1, 7)) => 4.1
 ('q', (1, 7)) => nothing
 ('p', (2, 3)) => 7.4
 ('q', (2, 3)) => 7.4
 ('p', (2, 5)) => nothing
 ('q', (2, 5)) => 5.6
 ('p', (3, 4)) => nothing
 ('q', (3, 4)) => nothing
 ('p', (3, 5)) => nothing
 ('q', (3, 5)) => nothing
 ('p', (4, 1)) => nothing
 ('q', (4, 1)) => nothing
 ('p', (4, 5)) => nothing
 ('q', (4, 5)) => nothing
 ('p', (5, 2)) => nothing
 ('q', (5, 2)) => 3.2

#or, if you prefere

julia> [ (person,pair...)=>person_values(person,pair...) for (person,pair) in
                               Iterators.product(Persons,Pairs)][:]
18-element Vector{Pair{Tuple{Char, Int64, Int64}}}:
 ('p', 1, 2) => 2.5
 ('q', 1, 2) => 2.5
 ('p', 1, 7) => 4.1
 ('q', 1, 7) => nothing
 ('p', 2, 3) => 7.4
 ('q', 2, 3) => 7.4
 ('p', 2, 5) => nothing
 ('q', 2, 5) => 5.6
 ('p', 3, 4) => nothing
 ('q', 3, 4) => nothing
 ('p', 3, 5) => nothing
 ('q', 3, 5) => nothing
 ('p', 4, 1) => nothing
 ('q', 4, 1) => nothing
 ('p', 4, 5) => nothing
 ('q', 4, 5) => nothing
 ('p', 5, 2) => nothing
 ('q', 5, 2) => 3.2

```

---

_[View the full topic](https://discourse.julialang.org/t/defining-a-parameter-out-of-pairs-and-values/82701)._
