commit f9192b43985e31d0b4c3f82029f0a628e3d8094b Author: Quentin Dufour Date: Fri Jul 22 17:11:39 2022 +0200 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..b2f5590 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# Interactive Programming + +Le but de ce dépôt est de prendre l'habitude de pratiquer "l'interactive programming" +avec Scheme. + +Le fichier shell.nix contient : + - Chez Scheme + - Emacs + - Geiser + +Pour commencer rapidement : + +``` +emacs -nw album.ss +``` + +Ensuite quelques raccourcis pratiques : + +``` +C-x C-s - Sauvegarder +C-x k - Fermer le buffer +C-c C-c - Evaluer la définition sous le curseur +C-c C-z - Ouvrir le REPL +``` diff --git a/album.ss b/album.ss new file mode 100644 index 0000000..811be0c --- /dev/null +++ b/album.ss @@ -0,0 +1,44 @@ +(define (flatten l) + (cond + ((not (list? l)) l) + ((null? l) '()) + ((list? (car l)) (append (flatten (car l)) (flatten (cdr l)))) + (#t (cons (car l) (flatten (cdr l)))))) + + +(define (tree path) + (cond + ((file-directory? path) + (map (lambda (item) (tree (string-append path "/" item))) (directory-list path))) + (#t path))) + +(define (string-suffix s n) + (let ([strlen (string-length s)]) + (substring s (- strlen n) strlen))) + +(define (pictures path) + (sort + string<=? + (filter + (lambda (filename) (string=? ".JPG" (string-suffix filename 4))) + (flatten (tree path))))) + + +(define (albumize path) + `(html () + (head () + (meta (charset "utf-8")) + (style () " +img { + display:block; + max-width: 100%; + margin: auto; + padding: 10px; +} + ")) + (body () + ,(map (lambda (filename) `(img (src ,filename))) (pictures path))))) + +;(define (sexpr->html + + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..3a66c16 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + nativeBuildInputs = [ + ((pkgs.emacsPackagesFor pkgs.emacs).emacsWithPackages + (epkgs: [ pkgs.emacs28Packages.geiser-chez ])) + pkgs.chez + ]; +}