Initial commit

This commit is contained in:
Quentin 2022-07-22 17:11:39 +02:00
commit f9192b4398
Signed by: quentin
GPG Key ID: E9602264D639FF68
3 changed files with 77 additions and 0 deletions

24
README.md Normal file
View File

@ -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
```

44
album.ss Normal file
View File

@ -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

9
shell.nix Normal file
View File

@ -0,0 +1,9 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [
((pkgs.emacsPackagesFor pkgs.emacs).emacsWithPackages
(epkgs: [ pkgs.emacs28Packages.geiser-chez ]))
pkgs.chez
];
}