Skip to content

Instantly share code, notes, and snippets.

View johnmyleswhite's full-sized avatar

John Myles White johnmyleswhite

View GitHub Profile
@johnmyleswhite
johnmyleswhite / overflow.R
Created February 20, 2023 14:48
R REPL overflow
x <- 1
x <- 2
x <- 3
x <- 4
x <- 5
x <- 6
x <- 7
x <- 8
x <- 9
x <- 10
@johnmyleswhite
johnmyleswhite / Julia ChatGPT.md
Created February 19, 2023 20:57
Julia ChatGPT

Write a blog post criticizing the Julia programming language

As a powerful high-level dynamic programming language, Julia has gained a lot of popularity among data scientists, engineers, and researchers. It is often considered a more efficient alternative to Python, R, and MATLAB, with a syntax that is easy to read and write. However, despite its strengths, there are some criticisms of Julia that should be taken into consideration.

First and foremost, the Julia programming language has a relatively small ecosystem compared to other programming languages. While it does have a growing community of developers, it does not have the same level of support and resources as languages like Python or Java. This can make it difficult for developers to find the necessary tools and libraries to accomplish their tasks.

Another major criticism of Julia is its lack of backwards compatibility. The language is still in its early stages of development, and as a result, changes to the syntax and features are common. While t

@johnmyleswhite
johnmyleswhite / primes.jl
Created November 15, 2022 00:28
Prime Sequence Generator
julia> import Printf: @printf
julia> f(x) = 1 / (x - floor(Int, x))
f (generic function with 1 method)
julia> function g(n, x₀ = 0.43233208718590286890)
x = x₀
for i in 1:n
x = f(x)
@printf("%d\t%s\n", i, x)
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
> 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
@johnmyleswhite
johnmyleswhite / lift.jl
Created October 31, 2020 15:48
wip_lift.jl
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,
struct ExpressionThunk
source::Any
thunk::Any
end
macro thunk(e)
quote
ExpressionThunk(
$(QuoteNode(e)),
() -> $(esc(e))
x = [1, 2]
y = [3, 4]
z = [x, y]
z′ = copy(z)
z′[1] === x
import DataFrames: DataFrame
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")
#!/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
#