Skip to content

Instantly share code, notes, and snippets.

View johnmyleswhite's full-sized avatar

John Myles White johnmyleswhite

View GitHub Profile
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)
│ 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 │
@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
johnmyleswhite / rsa.jl
Created March 2, 2014 05:00
Toy RSA implementation in Julia based on Matt Might's implementation in Scheme
# ---
# Author: Matthew Might
# Translator: John Myles White
# Site: http://matt.might.net/articles/implementation-of-rsa-public-key-cryptography-algorithm-in-scheme-dialect-of-lisp/
# ---
# ---
# Mathematical routines
# ---
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 / bfs_dfs.jl
Last active February 3, 2022 19:29
BFS and DFS for DAG's in Julia
function bfs(start_node::Any,
next_nodes::Function,
at_node::Function)
to_process = Array(Any, 0)
depths = Array(Int, 0)
push!(to_process, start_node)
push!(depths, 0)
while !isempty(to_process)
@johnmyleswhite
johnmyleswhite / differentiate.jl
Last active November 19, 2021 15:23
Symbolic Differentiation in Julia
differentiate(x::Number, target::Symbol) = 0
function differentiate(s::Symbol, target::Symbol)
if s == target
return 1
else
return 0
end
end