generics - 如何在 Julia 中指定无理数的类型?
问题描述
这是一个惊喜:
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.1.1 (2019-05-16)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> typeof((Base.MathConstants).e)
Irrational{:ℯ}
julia> typeof((Base.MathConstants).e) == Irrational{:e}
false
如何Irrational{:e}
在 Julia 1.1.1 中编写类型?
这个表达式在 Julia 0.5 中返回 true,但这仅仅是因为e
它是一个顶级标识符。从 0.5 到现在,语言发生了一些变化。我发现它e
已移至Base.MathConstants
,但我还没有弄清楚如何编写它的类型。REPL 说了一件事,但它说的不能用在==
表达式中。
解决方案
推荐阅读
- tags - 如何有条件地在 terraform 中定义 aws 资源标签?
- javascript - 使用 mongodb / mongoose 有条件地将 5-20k 文档的输入批次处理成一个包含多达一百万个文档的集合的有效方法是什么?
- c# - ViewModel 可以存储数据吗?
- java - 请解释 Spring Boot 中的 Pre-flight Filter 代码
- scala - 没有可用于案例类 Type 的 TypeTag
- javascript - 我对 JS 的 if-else 语句有几个问题
- c - 如何在循环中关闭和重新打开 GLUT 窗口?
- django - 为什么一个 Django 数据库查询有效,而类似的查询却没有
- angular - 这可以在非休息项目中使用 angular 2 吗?即替换thymeleaf 并保持其余项目Java 代码不变?
- qt - 什么时候必须调用 qRegisterMetaType()?