Swift 5 MIT LiCENSE build status

swift-interval

使用 Interval 类型的 Swift 区间算术 (Interval Arithmetic)

概要

import Interval         // needed only if you "make repl"
let about1 = 1.0 ± 0.1  // 0.9...1.1
about1+about1           // 1.8...2.2
about1-about1           // -0.2...0.2
about1*about1           // 0.81...1.21
about1/about1           // 0.818181818181818...1.22222222222222

先决条件

Swift 5.0 或更高版本,OS X 或 Linux。

用法

在您的项目中

只需将 interval.swift 添加到您的项目中即可。

使用 Playground

尽情使用本 Git 仓库中的 Interval.playground

当您使用它时,请确保打开左侧窗格(在您拉取代码后,它是关闭的,因为 UI 设置已通过 .gitignore 忽略)。如您所见,此 Playground 由多个页面和源文件组成。

在您的 Playground 中

只需将 interval.swift 拖放到 Sources 文件夹中。在 Git 中,Interval.playground/Sources/interval.swift 是指向它的符号链接。

通过命令行使用 REPL

带有 Xcode 的 OS X

git clone https://github.com/dankogai/swift-interval.git
cd swift-interval
make repl

Linux

git clone https://github.com/dankogai/swift-interval.git
cd swift-interval
make SWIFTPATH=${YOUR_SWIFT_PATH} repl # ${YOUR_SWIFT_PATH}=~/swift/usr/bin in my case

先决条件

Swift 5 或更高版本,OS X 或 Linux 用于构建。