Skip to content

Instantly share code, notes, and snippets.

@vendethiel
vendethiel / lb.js
Last active March 24, 2019 17:36 — forked from abrudz/lb.js
APL language bar
;(_=>{
let hc={'<':'&lt;','&':'&amp;',"'":'&apos;','"':'&quot;'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn
,tcs='<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡/_≢L=≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷'+
'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄on⍝->→aa⍺ww⍵VV∇--¯0~⍬'+
'^-∆^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇O:⍥O"⍥V~⍫\'\'`'
,lbs=['←←\nASSIGN',' ','++\nconjugate\nplus','--\nnegate\nminus','××\ndirection\ntimes','÷÷\nreciprocal\ndivide','**\nexponential\npower','⍟⍟\nnatural logarithm\nlogarithm',
'⌹⌹\nmatrix inverse\nmatrix divide','○○\npi times\ncircular','!!\nfactorial\nbinomial','??\nroll\ndeal',' ','||\nmagnitude\nresidue',
'⌈⌈\nceiling\nmaximum','⌊⌊\nfloor\nminimum','⊥⊥\ndecode','⊤⊤\nencode','⊣⊣\nsame\nleft','⊢⊢\nsame\nright',' ','==\nequal','≠≠\nnot equal',
'≤≤\nless than or equal to','<<\nless than','>>\ngreater than','≥≥\ngreater than or equal to','≡≡\ndepth\nmatch','≢≢\ntally\nnot matc
@vendethiel
vendethiel / main.p6
Created October 15, 2018 13:25 — forked from pmurias/main.p6
Hello World
say("Hello World");
@vendethiel
vendethiel / Commentated.scala
Last active May 26, 2020 11:02 — forked from SystemFw/Lib.scala
Shapeless: derive Slick's GetResult for arbitrary case classes
import slick.jdbc.{GetResult, PositionedResult}
import scala.annotation.implicitNotFound
import scala.reflect.runtime.universe.TypeTag
/**
* A type class that allows the user of GenericGetResult to support their own type.
* This is mostly used to support `newtype`s (like wrappers around UUIDs).
*
* A user just has to use the helper to make the type known to GenericGetResult.
my @a = ('99 bottles', 'take one down', '98 bottles');
for @a {
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc;
}
my @b = ('99 bottles', 'take one down', '98 bottles'), ('98 bottles', 'take one down', '97 bottles');
say @b.perl;
for @b {
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc;
}
macro $do {
rule {($($x = $y) (,) ...) $body} => {
(function ($x (,) ...) $body)($y (,) ...)
}
rule {$name ($($x = $y) (,) ...) $body} => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
macro $var {
macro null_helper {
rule {($processed ...) ($rest)} => {
$processed (.) ... . $rest
}
rule {($processed ...) ($rest_head $rest ...)} => {
$processed (.) ... . $rest_head
&& null_helper ($processed ... $rest_head) ($rest ...)
}
}
// y-combinator
macro $y {
rule {( $var )} => {
function(){
return function (f){
return f(f)
}(function(f){
return $var(function(x){
return f(f)(x);
})
macro to_string {
case $x => { (JSON.stringify({ $x: 0 }).slice(2, -4)) }
}
macro enum {
case [ $val:ident (,) ... ] => {
(function () {
var e = {
$( $val : (to_string $val) ) (,) ...
};
@vendethiel
vendethiel / do.sjs
Last active January 2, 2016 01:29 — forked from int3/gist:4013740
coffee's do, fix for new sweet.js
macro $do {
rule {($($x = $y) (,) ...) $body} => {
(function ($x (,) ...) $body)($y (,) ...)
}
rule {$name ($($x = $y) (,) ...) $body} => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
$do (a = 1, b = 2) {
@vendethiel
vendethiel / scheme.sjs
Last active January 2, 2016 01:29 — forked from disnet/scheme.sjs
scheme.sjs (forked from https://gist.github.com/disnet/3854258)
macro sexp {
rule {()} => {
;
}
rule {($p)} => {
$p
}
rule {($x $y)} => {
$x($y);
}