all repos — min @ eb3a75b75b51f523090113c9b3a2a8ba17a5c0a9

A small but practical concatenative programming language.

Documented logic module.
h3rald h3rald@h3rald.com
Sun, 04 Jun 2017 16:37:11 +0200
commit

eb3a75b75b51f523090113c9b3a2a8ba17a5c0a9

parent

56adef7f33e9f3aef903e12ee3f33ed31afe6061

M lib/min_logic.nimlib/min_logic.nim

@@ -13,7 +13,7 @@ proc logic_module*(i: In)=

let def = i.define() def.symbol(">") do (i: In): - var n2, n1: MinValue + var n1, n2: MinValue i.reqTwoNumbersOrStrings n2, n1 if n1.isNumber and n2.isNumber: if n1.isInt and n2.isInt:

@@ -28,7 +28,7 @@ else:

i.push newVal(n1.strVal > n2.strVal) def.symbol(">=") do (i: In): - var n2, n1: MinValue + var n1, n2: MinValue i.reqTwoNumbersOrStrings n2, n1 if n1.isNumber and n2.isNumber: if n1.isInt and n2.isInt:

@@ -43,7 +43,7 @@ else:

i.push newVal(n1.strVal >= n2.strVal) def.symbol("<") do (i: In): - var n2, n1: MinValue + var n1, n2: MinValue i.reqTwoNumbersOrStrings n1, n2 if n1.isNumber and n2.isNumber: if n1.isInt and n2.isInt:

@@ -58,7 +58,7 @@ else:

i.push newVal(n1.strVal > n2.strVal) def.symbol("<=") do (i: In): - var n2, n1: MinValue + var n1, n2: MinValue i.reqTwoNumbersOrStrings n1, n2 if n1.isNumber and n2.isNumber: if n1.isInt and n2.isInt:

@@ -113,7 +113,7 @@ i.push true.newVal

else: i.push false.newVal - def.symbol("int?") do (i: In): + def.symbol("integer?") do (i: In): if i.peek.kind == minInt: i.push true.newVal else:

@@ -131,7 +131,7 @@ i.push true.newVal

else: i.push false.newVal - def.symbol("bool?") do (i: In): + def.symbol("boolean?") do (i: In): if i.peek.kind == minBool: i.push true.newVal else:
M min.vimmin.vim

@@ -11,7 +11,7 @@

setl iskeyword=@,36-39,+,-,/,*,.,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append args ask atime bind bool bool? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dip dir? dirname div dprint dprint! dset dup encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent info insert int int? interpolate interval io join keep keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote uppercase unzip values version warn when which while with xor zip +syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append args ask atime bind bool boolean? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dip dir? dirname div dprint dprint! dset dup encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent info insert int integer? interpolate interval io join keep keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote uppercase unzip values version warn when which while with xor zip syntax match minDefaultSigil ;\<[:@'~!$%&$=<>#^*#+/]; contained
M site/contents/_includes/_defs_.mdsite/contents/_includes/_defs_.md

@@ -26,6 +26,9 @@ {{s => [string](class:kwd)}}

{{s1 => [string<sub>1</sub>](class:kwd)}} {{s2 => [string<sub>2</sub>](class:kwd)}} {{b => [bool](class:kwd)}} +{{b1 => [bool<sub>1</sub>](class:kwd)}} +{{b2 => [bool<sub>2</sub>](class:kwd)}} +{{b3 => [bool<sub>3</sub>](class:kwd)}} {{01 => [<sub>?</sub>](class:kwd)}} {{0p => [<sub>\*</sub>](class:kwd)}} {{1p => [<sub>\+</sub>](class:kwd)}}
M site/contents/_includes/_reference-logic.mdsite/contents/_includes/_reference-logic.md

@@ -1,1 +1,66 @@

-... +{@ _defs_.md || 0 @} + +{#op||&gt;||{{a1}} {{a2}}||{{b}}|| +> Returns {{t}} if {{a1}} is greater than {{a2}}, {{f}} otherwise. +> > %note% +> > Note +> > +> > Only comparisons among two numbers or two strings are supported.#} + +{#op||&gt;=||{{a1}} {{a2}}||{{b}}|| +> Returns {{t}} if {{a1}} is greater than or equal to {{a2}}, {{f}} otherwise. +> > %note% +> > Note +> > +> > Only comparisons among two numbers or two strings are supported.#} + +{#op||&lt;||{{a1}} {{a2}}||{{b}}|| +> Returns {{t}} if {{a1}} is smaller than {{a2}}, {{f}} otherwise. +> > %note% +> > Note +> > +> > Only comparisons among two numbers or two strings are supported.#} + +{#op||&lt;=||{{a1}} {{a2}}||{{b}}|| +> Returns {{t}} if {{a1}} is smaller than or equal to {{a2}}, {{f}} otherwise. +> > %note% +> > Note +> > +> > Only comparisons among two numbers or two strings are supported.#} + +{#op||==||{{a1}} {{a2}}||{{b}}|| +Returns {{t}} if {{a1}} is equal to {{a2}}, {{f}} otherwise. #} + +{#op||!=||{{a1}} {{a2}}||{{b}}|| +Returns {{t}} if {{a1}} is not equal to {{a2}}, {{f}} otherwise. #} + +{#op||and||{{b1}} {{b2}}||{{b3}}|| +Returns {{t}} if {{b1}} is equal to {{b2}}, {{f}} otherwise.#} + +{#op||boolean?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a boolean, {{f}} otherwise. #} + +{#op||dictionary?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a dictionary, {{f}} otherwise. #} + +{#op||float?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a float, {{f}} otherwise. #} + +{#op||or||{{b1}} {{b2}}||{{b3}}|| +Returns {{t}} if {{b1}} or {{b2}} is {{t}}, {{f}} otherwise.#} + +{#op||integer?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is an integer, {{f}} otherwise. #} + +{#op||not||{{b1}}||{{b2}}|| +Negates {{b1}}.#} + +{#op||number?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a number, {{f}} otherwise. #} + +{#op||quotation?||{{any}}||{{b}}|| +Returns {{t}} if {{any}} is a quotation, {{f}} otherwise. #} + +{#op||xor||{{b1}} {{b2}}||{{b3}}|| +Returns {{t}} if {{b1}} and {{b2}} are different, {{f}} otherwise.#} +
M tests/logic.mintests/logic.min

@@ -97,12 +97,12 @@ (true string? false ==) assert

(false string? false ==) assert (("a" 2 c) string? false ==) assert - ("a" int? false ==) assert - (1 int?) assert - (1.0 int? false ==) assert - (true int? false ==) assert - (false int? false ==) assert - (("a" 2 c) int? false ==) assert + ("a" integer? false ==) assert + (1 integer?) assert + (1.0 integer? false ==) assert + (true integer? false ==) assert + (false integer? false ==) assert + (("a" 2 c) integer? false ==) assert ("a" float? false ==) assert (1 float? false ==) assert

@@ -111,12 +111,12 @@ (true float? false ==) assert

(false float? false ==) assert (("a" 2 c) float? false ==) assert - ("a" bool? false ==) assert - (1 bool? false ==) assert - (1.0 bool? false ==) assert - (true bool?) assert - (false bool?) assert - (("a" 2 c) bool? false ==) assert + ("a" boolean? false ==) assert + (1 boolean? false ==) assert + (1.0 boolean? false ==) assert + (true boolean?) assert + (false boolean?) assert + (("a" 2 c) boolean? false ==) assert ("a" number? false ==) assert (1 number?) assert

@@ -133,4 +133,4 @@ (false quotation? false ==) assert

(("a" 2 c) quotation?) assert report - clear-stack+ clear-stack