Created
January 12, 2018 22:38
-
-
Save mihaimaruseac/7a971155b94869e16daa03d6d573072f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; GLOBAL AUXILIARY FUNCS, before working on real project code ; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; first, convert to Haskel-ish notations | |
(require srfi/1) | |
(define (oldtake l n) (take l n)) | |
(define (olddrop l n) (drop l n)) | |
; Haskell-ish take and drop | |
(define (take n l) (oldtake l n)) | |
(define (drop n l) (olddrop l n)) | |
; safe call of car -> returns '() if there's no answer | |
(define (head l) (if (null? l) '() (car l))) | |
; nubify = remove duplicates | |
(define (nub l) (reverse (nub-aux l '()))) | |
; repeat | |
(define (repeat x n) (if (>= 0 n) '() (cons x (repeat x (- n 1))))) | |
; Haskell-ish append, used below to implement set addition | |
(define ++ (lambda l (apply append l))) | |
(define +++ (lambda l (nub (apply ++ l)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment