- C# spec: http://www.microsoft.com/en-US/download/details.aspx?id=7029
- Hack references: http://docs.hhvm.com/manual/en/hack.nullable.php
- Swift optionals: http://www.matt.digital/comparing-c-nullable-types-and-swift-optionals/
- Rust option: https://doc.rust-lang.org/std/option/
- Scala option: http://www.scala-lang.org/api/current/scala/Option.html
- Haskell maybe: https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html
- SQL NULL: http://en.wikipedia.org/wiki/Null_(SQL)
- Dart DEP: https://github.com/chalin/DEP-non-null/blob/master/doc/dep-non-null-AUTOGENERATED-DO-NOT-EDIT.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JMWMacBookPro:CSVTools johnmyleswhite$ julia test/benchmark.jl | |
0.201432656 | |
0.206143505 | |
0.204748861 | |
0.201648006 | |
0.204058938 | |
0.200518181 | |
0.208433545 | |
0.19637816 | |
0.210459992 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
immutable NullableVector{T} | |
isnull::BitVector | |
values::Vector{T} | |
end | |
Base.length(nv::NullableVector) = length(nv.isnull) | |
function Base.getindex(nv::NullableVector{Float64}, i::Integer) | |
if nv.isnull[i] | |
return Nullable{Float64}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replace(s::String, pos::Integer, val::Char) | |
io = IOBuffer() | |
i = 0 | |
for c in s | |
i += 1 | |
if i != pos | |
write(io, c) | |
else | |
write(io, val) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 2147483647L + 1L | |
[1] NA | |
Warning message: | |
In 2147483647L + 1L : NAs produced by integer overflow | |
> 46341L * 46341L | |
[1] NA | |
Warning message: | |
In 46341L * 46341L : NAs produced by integer overflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID64 | ID32 | |
---|---|---|
9223372036854775807 | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# Problem 1: SELECT COUNT(DISTINCT(column_1)) from table_1 | |
############################################################################## | |
# Ideally, solution should look something like the following code | |
function count_distinct(table::TabularData) | |
values = Set{eltype(table.column_1)}() | |
for value in table.column_1 | |
push!(values, value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ | |
_ _ _(_)_ | A fresh approach to technical computing | |
(_) | (_) (_) | Documentation: http://docs.julialang.org | |
_ _ _| |_ __ _ | Type "help()" for help. | |
| | | | | | |/ _` | | | |
| | |_| | | | (_| | | Version 0.4.0-dev+4878 (2015-05-17 18:08 UTC) | |
_/ |\__'_|_|_|\__'_| | Commit b3116d4 (0 days old master) | |
|__/ | x86_64-apple-darwin14.3.0 | |
julia> xs = [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implement the unary operators: +, -, !, and ~ | |
for f in ( | |
:(Base.(:+)), | |
:(Base.(:-)), | |
:(Base.(:!)), | |
:(Base.(:~)), | |
) | |
@eval begin | |
function $(f){S}(x::Nullable{S}) | |
resval = $(f)(x.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implement the unary operators: +, -, !, and ~ | |
using NullableArrays | |
@noinline throw_error() = error() | |
for f in ( | |
:(Base.(:+)), | |
:(Base.(:-)), | |
:(Base.(:!)), |