diff --git a/.ikc3_history b/.ikc3_history
index 7922d2c..4095075 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,7 +1,3 @@
-HTTPd.routes
-a = :dir
-file = %{type: :dir}
-file.type
file.type == :dir
file = %{type: :dir, items = [%{type: file, items: []}]}
file = %{type: :dir, items: [%{type: file, items: []}]}
@@ -97,3 +93,7 @@ human_size(1024)
human_size(2024024)
human_size(100)
Str.size("abc")
+human_size(0)
+human_size((Uw) 114)
+type(1024 * 1024 * 1024 * 1024)
+human_size((Uw) 114)
diff --git a/lib/kc3/0.1/kc3.facts b/lib/kc3/0.1/kc3.facts
index 114ce48..ae7cac1 100644
--- a/lib/kc3/0.1/kc3.facts
+++ b/lib/kc3/0.1/kc3.facts
@@ -310,8 +310,11 @@ add {KC3, :symbol, KC3.fork}
replace {KC3.fork, :symbol_value, cfn S32 "fork" ()}
add {KC3, :symbol, KC3.system}
replace {KC3.system, :symbol_value, cfn Str "kc3_system" (List, Result)}
+add {KC3, :symbol, KC3.integer_reduce}
+replace {KC3.integer_reduce, :symbol_value, cfn Tag "kc3_integer_reduce" (Tag, Result)}
add {KC3, :symbol, KC3.human_size}
replace {KC3.human_size, :symbol_value, fn (size) {
+ size = integer_reduce(size)
if (size >= 1024 * 1024 * 1024 * 1024) do
s = size * 10 / 1024 / 1024 / 1024 / 1024
"#{s / 10}.#{s mod 10}Tb"
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index cb9e67d..b267d80 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -316,6 +316,16 @@ s_env * kc3_init (s_env *env, int *argc, char ***argv)
return env_init(env, argc, argv);
}
+s_tag * kc3_integer_reduce (const s_tag *tag, s_tag *dest)
+{
+ s_tag tmp;
+ if (! tag_init_copy(&tmp, tag))
+ return NULL;
+ tag_integer_reduce(&tmp);
+ *dest = tmp;
+ return dest;
+}
+
s_tag * kc3_let (const s_tag *tag, const s_block *block, s_tag *dest)
{
return env_let(&g_kc3_env, tag, block, dest);
diff --git a/libkc3/kc3_main.h b/libkc3/kc3_main.h
index fcd0812..7007d69 100644
--- a/libkc3/kc3_main.h
+++ b/libkc3/kc3_main.h
@@ -78,6 +78,7 @@ s_tag * kc3_facts_with_tags (s_facts *facts, s_tag *subject,
s_tag *predicate, s_tag *object,
s_fn *callback, s_tag *dest);
s_tag * kc3_identity (const s_tag *tag, s_tag *dest);
+s_tag * kc3_integer_reduce (const s_tag *tag, s_tag *dest);
bool kc3_load (const s_str *path);
s_tag * kc3_operator_find_by_sym (const s_sym * const *sym,
s_tag *dest);