Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/readoperator.jl @ 603:fbff4009c08a refactor/toml_operator_format
Add tests for parse_rational()
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 05 Dec 2020 13:07:07 +0100 |
parents | c2239c7cd71e |
children | 8ae63e775f9d |
comparison
equal
deleted
inserted
replaced
602:c2239c7cd71e | 603:fbff4009c08a |
---|---|
102 return Tuple(T.(parse_rational.(arr))) | 102 return Tuple(T.(parse_rational.(arr))) |
103 end | 103 end |
104 | 104 |
105 function parse_rational(str) | 105 function parse_rational(str) |
106 expr = Meta.parse(replace(str, "/"=>"//")) | 106 expr = Meta.parse(replace(str, "/"=>"//")) |
107 return eval(expr) | 107 return eval(:(Rational($expr))) |
108 end | 108 end |
109 | 109 |
110 function pad_tuple(t::NTuple{N, T}, n::Integer) where {N,T} | 110 function pad_tuple(t::NTuple{N, T}, n::Integer) where {N,T} |
111 if N >= n | 111 if N >= n |
112 return t | 112 return t |