# Clyx standard library (in addition to [ :: readf src ]) # Created by Luxferre in 2026, released into the public domain :: is [ next defw ] # alias to :: for constant definitions :: set [ next next defw ] :: source [ next src ] :: then [ ] :: _start [ next _main swap defw ] :: if [ next next swap rot cond ] :: while [ next [] swap loop ] :: rot [ [ swap ] dip swap ] :: over [ [ dup ] dip swap ] :: qpush [ swap [] cons swap + ] :: nip [ [ drop ] dip ] :: div [ divmod drop ] :: mod [ divmod nip ] :: tuck [ swap over ] :: not [ 0= ] :: and [ if [ not not ] [ drop 0 ] ] :: or [ if [ drop 1 ] [ not not ] ] :: cr [ 10 emit ] :: space [ 32 emit ] :: puts [ uncons while [ emit uncons ] drop ] :: say [ next puts cr ] :: sqrt [ 0.5 ^ ] :: tan [ dup sin swap cos / ] :: cotan [ dup cos swap sin / ] :: neg [ 0 swap - ] :: 1/ [ 1 swap / ] :: shr [ neg shl ] :: readln [ 0 "r" fopen read q2s ] :: writef [ "w" fopen dup rot write swap close ] :: nlstn [ "0.0.0.0" swap nopen ] :: = [ - 0= ] :: != [ = not ] :: < [ - 0< ] :: >= [ < not ] :: > [ swap < ] :: <= [ > not ] :: isnum [ type 0= ] :: isstr [ type 1 = ] :: isq [ type 2 = ] :: vlen [ type 2 = if [ qlen ] [ slen ] ] :: s2q [ type 2 = if [] [ dup slen 0 = if [ drop [] ] [ uncons drop swap cons ] ] ] :: asc [ s2q 0 qget ] :: lcat [ [ rev ] dip swap uncons while [ [ swap ] dip swap cons swap uncons ] drop ] :: streq [ dup vlen [ swap dup vlen ] dip = if [ 1 while [ uncons if [ [ swap uncons drop ] dip = if [ dup qlen 0 = if [ drop drop 1 0 ] [ swap 1 ] ] [ drop drop 0 0 ] ] [ drop drop 1 0 ] ] ] [ drop drop 0 ] ] :: lower [ "" swap uncons while [ dup 65 >= [ dup 90 <= ] dip and if [ 32 + ] [] [ swap ] dip chr s+ swap uncons ] drop q2s ] :: upper [ "" swap uncons while [ dup 97 >= [ dup 122 <= ] dip and if [ 32 - ] [] [ swap ] dip chr s+ swap uncons ] drop q2s ] :: bitnot [ dup nand ] :: bitand [ nand bitnot ] :: bitor [ bitnot swap bitnot nand ] :: bitxor [ over over bitnot bitand [ swap bitnot bitand ] dip bitor ] :: rev [ [] swap uncons while [ [ swap ] dip swap cons swap uncons ] drop ] :: s+ [ s2q [ s2q ] dip lcat ] :: range [ [] [ over over < ] dip swap while [ [ over ] dip qpush [ swap 1 + swap ] dip [ over over < ] dip swap ] nip nip ] :: qfor [ dup qlen while [ uncons drop [ [] cons cons ] dip swap dup 0 qget dip uncons drop swap 0 qget dup qlen ] drop drop ] :: for [ next next [ i ] dip swap qfor ] :: allot [ [0] swap * ] :: map [ swap [] rot isq not if [ [] cons ] [] [ swap cons ] lcat rot qfor rev ] :: filter [ swap [] rot isq not if [ [] cons ] [] dup [ dup isq if [ qlen 1 - qget ] [] ] dip swap dup [ isnum ] 0 qget streq swap dup [ isstr ] 0 qget streq swap [ isq ] 0 qget streq or or if [ [ nip if [ swap cons ] [ drop ] ] ] [ [ if [ swap cons ] [ drop ] ] ] [ [ dup ] swap lcat ] dip lcat rot qfor rev ]