aboutsummaryrefslogtreecommitdiff
path: root/neighborcat
diff options
context:
space:
mode:
authormryouse2022-05-25 01:05:21 +0000
committermryouse2022-05-25 01:05:21 +0000
commitcda02b2b28acb543e244346ba938c6efa36b6e1a (patch)
tree8cddd007db56ed40cd6d55c2dc043cb727c0c956 /neighborcat
parent1ab8d550f657c9abb546c402ff8fda6251e8eb18 (diff)
initial commit of a neighborcat implementation
Diffstat (limited to 'neighborcat')
-rw-r--r--neighborcat/neighborcat.neb66
1 files changed, 66 insertions, 0 deletions
diff --git a/neighborcat/neighborcat.neb b/neighborcat/neighborcat.neb
new file mode 100644
index 0000000..b134311
--- /dev/null
+++ b/neighborcat/neighborcat.neb
@@ -0,0 +1,66 @@
+(def HOME "/home/")
+(def PORCH "/porch/")
+(def BOWL "/porch/bowl/")
+(def USER (first ($ "whoami")))
+(def NAME "simon")
+(def PRONOUN "he")
+(def CAT "
+ |\ _,,,---,,_
+ /,`.-'`' -. ;-;;,_
+ |,4- ) )-,_..;\ ( `'-'
+'---''(_/--' `-'\_)
+")
+
+(func user-from-path (inp)
+ (first (rest (rest (split inp "/")))))
+
+; get all users who have a "porch"
+(func get-porches ()
+ (map user-from-path (glob (concat HOME "*" PORCH))))
+
+(func concat-star (inp)
+ (concat " * " inp))
+
+(func print-porches ()
+ (map print (map concat-star (get-porches))))
+
+(func get-eats (porch)
+ (glob (concat HOME porch BOWL "*")))
+
+(func get-porches-with-eats ()
+ (map get-eats (get-porches)))
+
+(func locate ()
+ (glob (concat HOME "*" PORCH NAME)))
+
+(func get-random-eats ()
+ (safe-first
+ (shuf
+ (safe-first
+ (shuf (get-porches-with-eats))))))
+
+(func safe-first (inp)
+ (if (empty? inp)
+ ()
+ (first inp)))
+
+(func wander ()
+ (print (concat "off " PRONOUN " goes!"))
+ (def current-location (locate))
+ (if (not (empty? current-location))
+ (print (concat "need to unlink: " (first current-location))))
+
+ ; this should probably return and not exit?
+ (def target-eats (get-random-eats))
+ (if (and (list? target-eats) (empty? target-eat)) (exit))
+
+ (def target-porch (user-from-path target-eats))
+
+ ) ; end of wander
+
+; options
+;(print-porches)
+;(print (->string (get-porches-with-eats)))
+;(print USER)
+;(print (->string (locate)))
+(wander)