Comments (6)
Hi @wayland - thanks for the feedback. The the .new constructor will parse Strings with the defn-extract regex
/^ ( <number> ) \s* ( <-[±]>* ) $/
[see Measure.rakumod line 102]
In this case, raku thinks the that 7.27i is a (complex) number. I think the best way to handle this corner case is to test for both number == complex && first letter = 'i' then insert space and reparse.
This to be closed in v0.0.4 - due in a few weeks.
from raku-physics-measure.
Sounds good! In the meantime, I'm splitting it apart and putting a space in manually.
from raku-physics-measure.
Here it is golfed. Turns out that defined assertion also gets Complex which we don't want.
my regex number is export {
\S+ #grab chars
<?{ +"$/" ~~ Real }> #assersion coerces via '+' to Numeric (Real && Complex)
##<?{ defined +"$/" }> #assert coerces via '+' to Real
}
#my $s = '7m';
#my $s = '7 m';
my $s = '7in';
#my $s = '7 in';
$s ~~ /^ ( <number> ) \s* ( <-[±]>* ) $/;
my $v = +"$0".Real if $0.defined;
my $u = "$1".Str if $1.defined;
say "extracting «$s»: v is «$v», u is «$u»";
from raku-physics-measure.
Final version a bit cleaner...
my regex number is export {
\S+ #grab chars
<?{ +"$/" ~~ Real }> #assert coerces via '+' to Numeric (Real || Complex)
}
and
$s ~~ /^ ( <number> ) \s* ( <-[±]>* ) $/;
my $v = +$0;
my $u = ~$1;
from raku-physics-measure.
Hi @wayland - I have completed this as a HotFix to the Master branch here at GitHub. You can get right away with:
zef uninstall Physics::Measure
zef install --verbose https://github.com/p6steve/raku-Physics-Measure.git
or similar
from raku-physics-measure.
Cool, thanks!
from raku-physics-measure.
Related Issues (20)
- Remove Length synonyms HOT 3
- .norm broken on m^3
- make round-to a class attr
- Does not install on Mac, with raku version 2022.3 HOT 1
- add proto method new(|) {*}
- check FuelEfficiency / Consumption defn HOT 1
- Make trig better
- Accept comma ',' in <number> part HOT 2
- use Intl::Token::Number
- round-val =0 HOT 1
- Test t/05-cvt.rakutest fails HOT 3
- add SpecificEnergy and ConsumptionRate
- REPL error HOT 1
- Minute angle parsing error HOT 2
- dimensional order of operations / moderately complex formulas HOT 2
- norm of SI should force Si prefix
- Failed test '$fe2.in-km/l'
- WHAT needs MOP for creation (v2) HOT 1
- make % a first class export
- Dependency not specified in META6.json HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raku-physics-measure.