From 0b185aa3b9592e0a7b8baeef8044e7e317e61f78 Mon Sep 17 00:00:00 2001 From: hellerve Date: Thu, 30 Jan 2020 16:43:58 +0100 Subject: [PATCH] cli: add morphers --- cli.carp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cli.carp b/cli.carp index 4870f51..4117cdb 100644 --- a/cli.carp +++ b/cli.carp @@ -84,6 +84,31 @@ optional arguments.") (Integer i) (str i) (Floating f) (str f) (Str s) (str s))) + + (defn to-int [x] + (match x + (Integer l) (Long.to-int l) + _ 0)) + + (defn to-long [x] + (match x + (Integer l) l + _ 0l)) + + (defn to-str [x] + (match x + (Str s) s + _ @"")) + + (defn to-float [x] + (match x + (Floating d) (Double.to-float d) + _ 0.0f)) + + (defn to-double [x] + (match x + (Floating d) d + _ 0.0)) ) (hidden Tag)