Skip to content

Instantly share code, notes, and snippets.

Avatar

C. Brenhin Keller brenhinkeller

View GitHub Profile
@brenhinkeller
brenhinkeller / verf.jl
Last active Jan 22, 2021
verf from SIMDPirates.jl updated to (I think!) work on Julia 1.6
View verf.jl
# Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Wolf Vollprecht and Martin Renou
# Copyright (c) 2016, QuantStack
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
@brenhinkeller
brenhinkeller / lispmode.jl
Last active Mar 20, 2021
Bare-bones REPL for Julia's secret built-in s-expression syntax, in under 30 lines
View lispmode.jl
to_expr(x) = x
to_expr(t::Tuple) = Expr(to_expr.(t)...) # Recursive to_expr implementation courtesy of Mason Protter
lisparse(x) = to_expr(eval(Meta.parse(x))) # Note that the `eval` in here means that any normal (non-s-expression) Julia syntax gets treated a bit like a preprocessor macro: evaluated _before_ the s-expression syntax is compiled and evaluated
function lispmode()
# READ
printstyled("\nlisp> ", color=:magenta, bold=true)
l = readline()
while l !== "(:exit)"
try # So we don't get thrown out of the mode
# EVAL