Skip to content

Commit

Permalink
Added syntax sugar
Browse files Browse the repository at this point in the history
  • Loading branch information
wallytutor committed Oct 17, 2024
1 parent 3dede89 commit 92d043c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/WallyToolbox/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ WallyToolbox.body

```@docs
WallyToolbox.defaultvalue
WallyToolbox.tuplefy
WallyToolbox.redirect_to_files
WallyToolbox.test_exhaustive
```
Expand Down
4 changes: 4 additions & 0 deletions src/wallytoolbox/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export head, tail, body
export defaultvalue
export tuplefy
export redirect_to_files
export test_exhaustive

Expand Down Expand Up @@ -67,6 +68,9 @@ body(z) = @view z[2:end-1]
"Syntax sugar for handling a possibly *nothing* value."
defaultvalue(p, q) = isnothing(p) ? q : p

"Syntax sugar for converting a dictionary into a named tuple."
tuplefy(d) = NamedTuple{Tuple(keys(d))}(values(d))

# TODO document these or deprecate?
in_range_cc(x, lims) = lims[1] <= x <= lims[2]
in_range_co(x, lims) = lims[1] <= x < lims[2]
Expand Down

0 comments on commit 92d043c

Please sign in to comment.