Personal StdLibs

Hi All,

Having written a couple of Julia programs and working on some packages, I’ve started to group things I use very often and find handy into my personal (local) StdLib or whatever you want to call it.
I assume that a lot of the people on this forum have similar constructions.
I thought it would be cool to be able to share these things to a central entity (some github organisation or repo with folders referring to the Author?)
If it doesn’t exist yet, does this sound like a good idea?
If this already exists, i’d very much like to hear about it since I think there’s great value to be had from being able to read/use/understand code that other coders use on a dayly basis.

Hi,

I have to say that I was thinking about the same this week. I have some very simple helper function just because I wrote the same pattern in many places and I find ugly to use the pattern instead of a function.

They are like:

oneless(x) = x - one(x)
onemore(x) = x + one(x)
two(::Type{T}) where {T} = convert(T, 2)
two(x :: T) where {T} = convert(T, 2)
ispositive(x) :: Bool = x > zero(x)

I was thinking of just creating my personal package and add it as dependency of any new packages I wrote. A centralized solution would be interesting to avoid spawning hundreds (or thousands) of personal packages, however, would need some coordination and a maintainer to keep (also, it could end up as a large package that you use just a small part).

Note that for code like this you should use oneunit instead of one if you want it to also work with dimensionful types like in Unitful.jl. (Writing library code that is generic enough to work with dimensionful types requires a bit of care.)

1 Like

This comes up every now and again. It seems that there are any number of others who do something similar and would be happy to contribute whatever of theirs the community finds generally helpful or specifically wondrous. I’m game.

1 Like

I remember to have seen the dimensionful and dimensionless terms used before. Reading the description of oneunit unfortunately was not very enlightening…

Returns T(one(x)), where T is either the type of the argument or (if a type is passed) the argument. This differs from one for dimensionful quantities: one is dimensionless (a multiplicative identity) while oneunit is dimensionful (of the same type as x, or of type T).

Where I could read an article tackling the difference between both concepts? The only thing I gathered seems that one(T) is only defined if type T has an multiplication operator and f(x) = one(T) * x is an identity function. Is this the difference?

Yes I agree that it would end up like a large package. I’m not sure if I would actually turn it into an actual package that you depend on, rather some kind of archive where you can copy paste parts from that are useful to your code. I’m not entirely sure how to handle the logistics. Another possibility would be that each makes their own package and then just a site grouping all of them. Idk

See Unitful.jl