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

make lazymap work with uncountable sets and rand #129

Open
zsunberg opened this issue Nov 1, 2020 · 0 comments
Open

make lazymap work with uncountable sets and rand #129

zsunberg opened this issue Nov 1, 2020 · 0 comments

Comments

@zsunberg
Copy link

zsunberg commented Nov 1, 2020

I would like to be able to do the following (not exactly this, but something similar):

struct Interval
    low::Float64
    high::Float64
end

Base.rand(rng::AbstractRNG, s::Random.SamplerTrivial{Interval}) = s[].low + (s[].high-s[].low)*rand(rng)

m = Lazy.lazymap(x->round(Int, x), Interval(1.0, 3.0))
rand(m)

There are two steps:

  1. Create a version of lazymap for things that are not iterable (and figure out how to detect if something is iterable).
  2. Create a method of rand to call through to the original object and apply the mapped function.

Is this the right package to implement it in, or is it outside the scope? (even if the uncountable set part is outside the scope, it would be nice to make rand work for finite sets)

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

No branches or pull requests

1 participant