View do_invisible.R
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
johnmyleswhite@foobar:~/R-4.1.2$ bin/R | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible | |
do_invisible |
View invisible_is_weird.R
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
> visible_plus_one <- function (x) {x} | |
> | |
> invisible_plus_one <- function (x) {invisible(x)} | |
> | |
> visible_plus_one(1) | |
[1] 1 | |
> invisible_plus_one(1) | |
> | |
> visible_plus_one(1) + 1 | |
[1] 2 |
View lift.jl
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
import MacroTools: postwalk | |
function missing_check(es) | |
if length(es) == 0 | |
false | |
elseif length(es) == 1 | |
Expr(:call, :ismissing, es[1]) | |
elseif length(es) == 2 | |
Expr( | |
:call, |
View thunk.jl
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
struct ExpressionThunk | |
source::Any | |
thunk::Any | |
end | |
macro thunk(e) | |
quote | |
ExpressionThunk( | |
$(QuoteNode(e)), | |
() -> $(esc(e)) |
View df_deep_copy.jl
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
x = [1, 2] | |
y = [3, 4] | |
z = [x, y] | |
z′ = copy(z) | |
z′[1] === x | |
import DataFrames: DataFrame |
View example2.jl
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
import Plots | |
r = range(0.0, 1.0, length=512) | |
p = Plots.plot( | |
r, | |
x -> x^2 * (1 - x)^2, | |
) | |
Plots.png(p, "output2.png") |
View example.R
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
#!/usr/bin/Rscript | |
png("output.png") | |
curve(x^2 * (1 - x)^2, from = 0, to = 1) | |
dev.off() | |
# time Rscript example.R | |
# null device | |
# 1 | |
# |
View logistic_comparisons.jl
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
julia> import BenchmarkTools: @btime | |
julia> @inline _logistic_bounds(x::Float16) = (Float16(-16.64), Float16(7.625)) | |
_logistic_bounds (generic function with 1 method) | |
julia> @inline _logistic_bounds(x::Float32) = (-103.27893f0, 16.635532f0) | |
_logistic_bounds (generic function with 2 methods) | |
julia> @inline _logistic_bounds(x::Float64) = (-744.4400719213812, 36.7368005696771) | |
_logistic_bounds (generic function with 3 methods) |
View expr_kinds.txt
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
│ Row │ expr_type │ count │ percentage │ | |
│ │ Any │ Int64 │ Float64 │ | |
├─────┼────────────────────────────────┼────────┼─────────────┤ | |
│ 1 │ ExprKind{:outer} │ 1 │ 0.000226006 │ | |
│ 2 │ ExprKind{:/=} │ 1 │ 0.000226006 │ | |
│ 3 │ ExprKind{:typed_vcat} │ 1 │ 0.000226006 │ | |
│ 4 │ ExprKind{:.+=} │ 1 │ 0.000226006 │ | |
│ 5 │ ExprKind{:%=} │ 3 │ 0.000678017 │ | |
│ 6 │ ExprKind{:⊻=} │ 7 │ 0.00158204 │ | |
│ 7 │ ExprKind{:.=} │ 8 │ 0.00180804 │ |
View runtimes.jl
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
import RCall: @R_str | |
function runtimes(n_reps) | |
times = Array{Float64}(undef, n_reps) | |
x = rand(10_000_000) | |
for i in 1:n_reps | |
times[i] = @elapsed sum(x) | |
end | |
times | |
end |
NewerOlder