Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pmap_qto #9

Merged
merged 17 commits into from
Dec 24, 2023
Merged

pmap_qto #9

merged 17 commits into from
Dec 24, 2023

Conversation

ElianHugh
Copy link
Owner

@ElianHugh ElianHugh commented Dec 22, 2023

Resolves #8.

Changes:

  • Introduces a pmap_qto to compliment the map_qto function introduced by @elipousson
  • map_qto should be slightly more performant (function building is done outside the map call)
  • collapse and sep are now passed to .type functions where relevant
  • Add tests for pmap_qto and map_qto

pmap_qto mirrors purrr's pmap function, allowing for mapping over lists in parallel. For example:

pmap_qto(
     list(
         list("Answer:", "Answer:", "Answer:"),
         list("Yes", "No", "Yes")
     )
)

#> [[1]]
#> Answer: Yes
#>
#> [[2]]
#> Answer: No
#>
#> [[3]]
#> Answer: Yes

We can pass custom functions just like the original pmap function

pmap_qto(
    mtcars[1L:3L, 1L:3L],
    function(mpg, cyl, disp) {
        qto_li(
            .list = list(
                sprintf("mpg is: %s", mpg),
                sprintf("cyl is: %s", cyl),
                sprintf("disp is: %s", disp)
            )
        )
    }
)

#> [[1]]
#> 
#> * mpg is: 21
#> * cyl is: 6
#> * disp is: 160
#> 
#> [[2]]
#> 
#> * mpg is: 21
#> * cyl is: 6
#> * disp is: 160
#> 
#> [[3]]
#> 
#> * mpg is: 22.8
#> * cyl is: 4
#> * disp is: 108
#> 

@ElianHugh ElianHugh marked this pull request as draft December 22, 2023 04:58
- pmap/map shouldn't be resolving the mapper every iteration
- pmap should now be using the outer dots of the pmap function
- collapse and sep weren't being passed to qto_* functions if they were being used via the .type parameter. we now prefill this using an anonymous func
collapse and sep aren't passed to div or callout
@ElianHugh ElianHugh marked this pull request as ready for review December 23, 2023 21:56
@ElianHugh ElianHugh merged commit 0f454d5 into main Dec 24, 2023
6 checks passed
@ElianHugh ElianHugh deleted the pmap_qto branch December 24, 2023 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pmap_qto
1 participant