From f567881d6526d89d56d367ab6000df7c043ddaac Mon Sep 17 00:00:00 2001 From: Michael Reed <18372368+chakravala@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:56:32 -0400 Subject: [PATCH] refined countvalues aliasing --- Project.toml | 2 +- src/StaticVectors.jl | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index aea7a87..1a6215b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "StaticVectors" uuid = "20fadf95-9e3d-483c-97cd-cab2760e7998" authors = ["Michael Reed"] -version = "1.0.5" +version = "1.0.6" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/StaticVectors.jl b/src/StaticVectors.jl index c449275..df0fe0b 100644 --- a/src/StaticVectors.jl +++ b/src/StaticVectors.jl @@ -64,7 +64,32 @@ const SVector,MVector,SizedVector = Values,Variables,FixedVector end +""" + count(a::Int,b::Int) -> Values + +Generates an incremental `Int` list of `Values` from `a` to `b`. +""" +@pure Base.count(a::Int,b::Int) = countvalues(a,b) + +""" + countvalues(a::Int,b::Int) -> Values + +Generates an incremental `Int` list of `Values` from `a` to `b`. +""" @pure countvalues(a::Int,b::Int) = Values{max(0,b-a+1),Int}(a:b...) + +""" + evenvalues(a::Int,b::Int) -> Values + +Generates an `Int` list of `Values` by skipping in twos from `a` to `b`. +""" @pure evenvalues(a::Int,b::Int) = Values{((b-a)รท2)+1,Int}(a:2:b...) +""" + evens(a::Int,b::Int) -> Values + +Generates an `Int` list of `Values` by skipping in twos from `a` to `b`. +""" +const evens = evenvalues + end # module