Tamgu(탐구)是一个函数式、命令式与逻辑一体化(FIL,Functional、Imperative、Logical)的编程语言,主要用于注解和数据扩充。
Tamgu是一种多线程编程语言,特征包括:
接近Python的命令式风格,但具有强大的类型系统。受Haskell启发的函数式风格,可自由地与命令式范式相结合。由Prolog启发的逻辑风格,可以自由地与命令式和函数式范式相结合。使用Tamgu,可以对于编程中的每个特定问题,选择最合适的形式,并自由地混合函数式、命令式和逻辑方法,以实现最具表现力但最紧凑的代码。
此外,Tamgu还提供了一个注解语言实现,它提供了一个结合了词汇和规则的综合规则机制,允许以有效的方式检测文本中的复杂模式。它提供了许多功能,同时也提供了许多库,有助于设计和实现复杂文档的注解方案。
CodeExample
//Animperativelanguageinti=10;strings="20";------------------------------------------------------------------------------------//Containersmapm={'a':1,'b':2};//allsortsofcontainerstreemapt={"u":10,'v':'toto'};vectorv=[1,2,3,"a","b"];ivectoriv=[1..10];//iv=[1,2,3,4,5,6,7,8,9,10]iv=[1,3..10];//iv=[1,3,5,9]------------------------------------------------------------------------------------//Functions,threadsandframesfunctionmycall(inti,strings){...}//functionsthreadmythread(inti,strings){...}//threadsframemyclass{...}//classdefinition------------------------------------------------------------------------------------//NativeKoreanstringsupports="에버랜드알쏭달쏭Quiz";if(s[0].ishangul())println("Ok");uvectordec=s.jamo();//['ᄋ','ᅦ','ᄇ','ᅥ','ᄅ','ᅢ','ᆫ','ᄃ','ᅳ'...]dec=s.romanization();//['-/ng','e','b','eo','r/l','ae','n','d',...]------------------------------------------------------------------------------------//FunctionalapproachbasedonHaskellivectoriv=[1..20];//alistofintegersbetween1and20iv.shuffle();//Theorderoftheelementsisnowrandom.<fastsort([])=[]>;//ifthelistisempty,wereturnanempty"list"<fastsort([fv:v])=minlist&&&fv&&&maxlistwhere//wemergethedifferentlist...letminlist=fastsort(<filter(<=fv)v>),//wesortthelistwithelementssmallerthanfvletmaxlist=fastsort(<filter(>fv)v>)>;//wesortthelistwithelementslargerthanfv//wecancallafunctionaldefinitionasregularcodev=fastsort(iv);------------------------------------------------------------------------------------//Predicatesconcat([],?X,?X).concat([?H|?T],?Y,[?H|?Z]):-concat(?T,?Y,?Z).//Youcanmixfreelyyourpredicatedefinitionwithsomeregulartamgucodev=concat(["english",'russian',"french"],['spanish'],?L);println(v);//["english",'russian',"french","spanish"]注解示例
//Wedefinesomelexicalrules(startingwitha"@")@food<-burger.@food<-tartare.//Ourrule:if"thefood"wordisfoundinasentence,thenwereturna"meal"labelmeal<-"the",#food.//Weneedaspecificobjecttoscanasentenceannotatorr;//asentencestringsentence="Here,theburgerandthetartarearedelicious."vectorv=r.parse(sentence);//Result:v=[['meal',[10,16]],['meal',[25,32]]]//Itreads:two'meal'werefoundatposition10-16andposition25-32...
评论