diff options
Diffstat (limited to 'com/simatime')
-rwxr-xr-x | com/simatime/bild.scm | 8 | ||||
-rw-r--r-- | com/simatime/core.scm | 46 | ||||
-rw-r--r-- | com/simatime/repl.scm | 27 |
3 files changed, 18 insertions, 63 deletions
diff --git a/com/simatime/bild.scm b/com/simatime/bild.scm index 44f6c74..d924b29 100755 --- a/com/simatime/bild.scm +++ b/com/simatime/bild.scm @@ -1,6 +1,4 @@ -#!/usr/bin/env bash -exec guile -e "(@ (com simatime bild) main)" -s "$0" "$@" -!# +;; ;; bild - a simple build tool ;; ;;; Notice: @@ -140,8 +138,8 @@ exec guile -e "(@ (com simatime bild) main)" -s "$0" "$@" (target (cadr args)) (path (ns->path target))) (display (fmt ":: bild ~a...\r" target)) - (sh/exec (fmt "nix build -f ~a/default.nix -o ~a/_bild/~a ~a" - root root path target)) + (sh/exec (fmt "nix build -f ~a/default.nix ~a" + root target)) (display (fmt ":: bilt ~a" target)))) (define ns? symbol?) diff --git a/com/simatime/core.scm b/com/simatime/core.scm index 6a4f09d..611aaca 100644 --- a/com/simatime/core.scm +++ b/com/simatime/core.scm @@ -1,21 +1,12 @@ (define-module (com simatime core)) -;; -;; old core, do i still need this? -;; - -(define (not x) (if x #f #t)) -(define (null? obj) (if (eqv? obj '()) #t #f)) -(define (list objs) objs) -(define (identity obj) obj) (define (flip f) (lambda (x y) (f y x))) (define (curry f a) (lambda (b) (apply f (cons a (list b))))) -(define (compose f g) (lambda (x) (f (apply g x)))) -(define zero? (curry = 0)) -(define positive? (curry < 0)) -(define negative? (curry > 0)) -(define (odd? n) (= (mod n 2) 1)) -(define (even? n) (= (mod n 2) 0)) +(define pos? + (curry < 0)) + +(define neg? + (curry > 0)) (define (foldr f end lst) (if (null? lst) @@ -27,40 +18,17 @@ acc (foldl f (f acc (car lst)) (cdr lst)))) -(define fold foldl) +(define fold foldl) (define (unfold f init pred) (if (pred init) (cons init '()) (cons init (unfold f (f init) pred)))) -(define (mem* pred op) - (lambda (acc next) - (if (and (not acc) (pred (op next))) - next - acc))) - (define (sum lst) (fold + 0 lst)) (define (produce lst) (fold * 0 1 lst)) -(define (max nums) - (fold (lambda (x y) (if (> x y) x y)) - (car nums) (cdr nums))) - -(define (min nums) - (fold (lambda (x y) (if (< x y) x y)) - (car nums) (cdr nums))) - -(define (length lst) (fold (lambda (x y) (+ x 1)) 0 lst)) -(define (reverse lst) (fold (flip cons) '() lst)) -(define (memq obj lst) (fold (mem* (curry eq? obj) identity) #f lst)) -(define (memv obj lst) (fold (mem* (curry eqv? obj) identity) #f lst)) -(define (member obj lst) (fold (mem* (curry equal? obj) identity) #f lst)) -(define (assq obj alist) (fold (mem* (curry eq? obj) car) #f alist)) -(define (assv obj alist) (fold (mem* (curry eqv? obj) car) #f alist)) -(define (assoc obj alist) (fold (mem* (curry equal? obj) car) #f alist)) -(define (map f lst) (foldr (lambda (x y) (cons (f x) y)) '() lst)) -(define (filter pred lst) (foldr (lambda (x y) (if (pred x) (cons x y) y)) '() lst)) +(define count length) ;; diff --git a/com/simatime/repl.scm b/com/simatime/repl.scm index 3d2f6d9..bae7e8f 100644 --- a/com/simatime/repl.scm +++ b/com/simatime/repl.scm @@ -1,23 +1,5 @@ (define-module (com simatime repl) - #:use-module ((ice-9 ftw) #:prefix ftw:) - #:export (pr prn pwd ls cd)) - - -;; -;; shell-like stuff -;; -(use-modules ((ice-9 ftw) #:prefix ftw:)) - -(define (pwd) - (regexp-substitute/global - #f "/home/ben" (getcwd) 'pre "~" 'post)) - -(define (ls) - (ftw:scandir (getcwd))) - -(define (cd path) - (chdir path) - (ls)) + #:export ()) ;; @@ -32,3 +14,10 @@ ;; (getenv "USER") ;; (vector-ref (uname) 1) ;; (pwd)))) + +;; TODO(bsima): (doc x) +;; TODO(bsima): (src x) +;; TODO(bsima): ,src command +;; TODO(bsima): ,shell command +;; TODO(bsima): how to load this file on startup? +;; for ,src and ,shell https://github.com/NalaGinrut/nala-repl |