测量单位是F#特有的吗? [英] Are units of measurement unique to F#?

查看:109
本文介绍了测量单位是F#特有的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读安德鲁肯尼迪的博客文章系列 F#中的度量单位,这在很多情况下很有意义。有没有其他语言有这样的系统?编辑:更清楚地说,我的意思是灵活的测量系统单位,您可以任意定义您自己的系统。

/ p>

解决方案

TI-89 BASIC是否计数?输入 54_kg *(_c ^ 2),它会给你一个以焦耳为单位的答案。



除此之外,我不记得任何内置的语言,但任何带有体面的OO的语言都应该让你自己的语言变得简单。这意味着其他人可能已经做了。

Google确认。例如,这是Python中的一个。可以很容易地修改 __ repr __ 以选择最合适的派生单位等。

CPAN有几个Perl模块:物理::单元,< a href =http://search.cpan.org/~ajgough/Data-Dimensions-0.04/lib/Data/Dimensions.pm =nofollow noreferrer> Data :: Dimensions , Class :: Measure Math :: Units :: PhysicalValue ,以及其他一些会转换,但不会真正将价值与单位结合。


I was reading Andrew Kennedy's blog post series on units of measurement in F# and it makes a lot of sense in a lot of cases. Are there any other languages that have such a system?

Edit: To be more clear, I mean the flexible units of measurement system where you can define your own arbitrarily.

解决方案

Does TI-89 BASIC count? Enter 54_kg * (_c^2) and it will give you an answer in joules.

Other than that, I can't recall any languages that have it built in, but any language with decent OO should make it simple to roll your own. Which means someone else probably already did.

Google confirms. For example, here's one in Python. __repr__ could easily be amended to also select the most appropriate derived unit, etc.

CPAN has several modules for Perl: Physics::Unit, Data::Dimensions, Class::Measure, Math::Units::PhysicalValue, and a handful of others that will convert but don't really combine values with units.

这篇关于测量单位是F#特有的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆