Skip to content

Instantly share code, notes, and snippets.

View martialboniou's full-sized avatar

Martial martialboniou

  • Brittany
View GitHub Profile
@martialboniou
martialboniou / ps-inline.shen
Last active December 18, 2015 12:09
ps-inline function to reduce KLambda code in terms of primitives (https://groups.google.com/forum/#!topic/Qilang/Jb9YR1pA_SA)
(define zip
X [] -> []
[] Y -> []
X Y -> (zip-help X Y []))
(define zip-help
X Y Acc -> (reverse Acc) where (or (empty? X) (empty? Y))
[X | Xs] [Y | Ys] Acc -> (zip-help Xs Ys [(@p X Y) | Acc]))
(define substitute
@martialboniou
martialboniou / cl-define+destroy_v2.shen
Created December 27, 2012 19:07
A better prototype for clean define (here: cc-define) and destroy (here: destroy-it) shen functions for partial applications' case in Shen. Usage of call graph to maintain a list of callers to force recompilation of kl code in a host language which doesn't support curry.
\* This script is aimed to run on Shen 7.1 on any Common Lisp port *\
(package property-vector-utilities- [delete-properties]
(define delete-properties
Ref Properties Vec -> (let Pos (hash Ref (limit Vec))
Content (trap-error (<-vector Vec Pos) (/. (protect E) (error "no vector element to retract")))
DeprecatedEntries (map (/. X [Ref X]) Properties)
NewContent (remove-entries DeprecatedEntries Content)
(do (vector-> Vec Pos NewContent)
@martialboniou
martialboniou / cl-define-tests.shen
Last active December 10, 2015 02:38
Test cl-define.shen
\* This script is aimed to run on Shen 7.1 on any Common Lisp port *\
(load "cl-destroy.shen")
(load "cl-define.shen")
\* old behavior *\
(do (output "*** OLD BEHAVIOR ***~%") start)
(define sad-foo X -> (sad-bar X))
(define sad-bar X Y -> (+ X Y))
(trap-error ((sad-foo 5) 2) (/. E (do (output "+++expected error on CL: ~A+++~%" (error-to-string E)) expected-error)))
@martialboniou
martialboniou / cl-define.shen
Created December 24, 2012 12:00
CL fast prototyping of clean define for partial applications in Shen
\* This script is aimed to run on Shen 7.1 on any Common Lisp port *\
\* (load "cl-destroy.shen") *\
\* BEGIN: fast prototyping solution for partial application compatible define *\
(package cl-define [caller-list cc-define]
\* vectors util from vectors library *\
@martialboniou
martialboniou / cl-destroy.shen
Created December 24, 2012 11:58
CL version of destroy for Shen
\* This script is aimed to run on Shen 7.1 on any Common Lisp port *\
(package cl-destroy- [destroy-it]
(define simple-retract
X Vec -> (let Pos (hash X (limit Vec))
(vector-> Vec Pos (fail))))
(define retract
X Vec -> (let Pos (hash X (limit Vec))
Content (trap-error (<-vector Vec Pos) (/. (protect E) (error "no vector element to rectract")))
@martialboniou
martialboniou / gist:2193962
Created March 25, 2012 13:34
temporary simple vimrc workaround
" .vimrc
if has('win32') || has('win64')
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles
if has('gui_running')
if filereadable("C:\\Windows\\Fonts\\DejaVuSansMono.ttf")
set guifont=DejaVu_Sans_Mono:h10
elseif
set guifont=Consolas:h9:cANSI
endif
endif
@martialboniou
martialboniou / js-shen-strings-test.js
Created February 27, 2012 11:20
Shen string functions for UCS-2 and UTF-8 JavaScript REPL
if (("€").length === 3)
{
// UCS2 is not normal encoding
// suppose well-formed UTF-8 is used
// should work with SpiderMonkey multibytes representation
function string_$gt$n(str)
{
fB=str.charCodeAt(0);
return (fB < 128) ? fB :
@martialboniou
martialboniou / utf8-shen.shen
Created February 11, 2012 18:46
utf8 encoding read-file functions for shen
\* functions to read UTF-8 files & sequences *\
(synonyms bytelist (list number))
(define nlist->utf8
{ (list number) --> bytelist }
[] -> []
X -> (nlist->utf8- X []))
(define nlist->utf8-
\* Build Lisp CxRS *\
\* CC Part *\
(defcc <expr> X <expr> := [X | <expr>]; <e> := [];)
(defcc <a-d-to-head-tail>
"a" <a-d-to-head-tail> := [head <a-d-to-head-tail>];
"d" <a-d-to-head-tail> := [tail <a-d-to-head-tail>];
"r" <expr> := <expr>;)
(defcc <cxr?>
"c" "a" <a-d-to-head-tail> := [head <a-d-to-head-tail>];
@martialboniou
martialboniou / .stumpwmrc
Created January 23, 2012 19:30 — forked from shes-a-skeeze/.stumpwmrc
stumpwm
;; MY STUMPWM
(in-package :stumpwm)
(setq *mouse-focus-policy* :click)
(setf *startup-message*
"everything seems to be just fine")
(set-contrib-dir "/home/sleeze/.config/stumpwm/contrib")
(setf *suppress-frame-indicator* t)
;; Directories