函数式、命令式与逻辑一体化编程语言 Tamgu

BSD-3-Clause
C/C++ 查看源码»
跨平台
2019-09-19
h4cd

Tamgu(탐구)是一个函数式、命令式与逻辑一体化(FIL,Functional、Imperative、Logical)的编程语言,主要用于注解和数据扩充。

Tamgu 是一种多线程编程语言,特征包括:

  • 接近 Python 的命令式风格,但具有强大的类型系统。
  • 受 Haskell 启发的函数式风格,可自由地与命令式范式相结合。
  • 由 Prolog 启发的逻辑风格,可以自由地与命令式和函数式范式相结合。

使用 Tamgu,可以对于编程中的每个特定问题,选择最合适的形式,并自由地混合函数式、命令式和逻辑方法,以实现最具表现力但最紧凑的代码。

此外,Tamgu 还提供了一个注解语言实现,它提供了一个结合了词汇和规则的综合规则机制,允许以有效的方式检测文本中的复杂模式。它提供了许多功能,同时也提供了许多库,有助于设计和实现复杂文档的注解方案。

Code Example

//An imperative language

int i=10;
string s="20";
------------------------------------------------------------------------------------
//Containers

map m = {'a':1, 'b':2}; //all sorts of containers
treemap t = {"u":10, 'v':'toto'};
vector v = [1,2,3,"a","b"];
ivector iv = [1..10]; //iv = [1,2,3,4,5,6,7,8,9,10]
iv = [1,3..10]; //iv = [1,3,5,9]
------------------------------------------------------------------------------------
//Functions, threads and frames

function mycall(int i, string s) {...} //functions
thread mythread(int i, string s) {...} //threads
frame myclass {...} //class definition
------------------------------------------------------------------------------------
//Native Korean string support

s="에버랜드 알쏭달쏭 Quiz";
if (s[0].ishangul()) println("Ok");
uvector dec = s.jamo(); //['ᄋ','ᅦ','ᄇ','ᅥ','ᄅ','ᅢ','ᆫ','ᄃ','ᅳ'...]
dec = s.romanization(); //['-/ng','e','b','eo','r/l','ae','n','d',...]
------------------------------------------------------------------------------------
//Functional approach based on Haskell

ivector iv = [1..20]; //a list of integers between 1 and 20
iv.shuffle(); //The order of the elements is now random.

<fastsort([]) = []>;  //if the list is empty, we return an empty "list"
<fastsort([fv:v]) =  minlist &&& fv &&& maxlist where //we merge the different list...
    let minlist = fastsort(<filter (<=fv) v>), //we sort the list with elements smaller than fv
    let maxlist = fastsort(<filter (>fv) v>)>; //we sort the list with elements larger than fv

//we can call a functional definition as regular code
v=fastsort(iv); 

------------------------------------------------------------------------------------
//Predicates

concat([],?X,?X).
concat([?H|?T],?Y, [?H|?Z]) :- concat(?T,?Y,?Z).

//You can mix freely your predicate definition with some regular tamgu code
v=concat(["english",'russian',"french"],['spanish'],?L);
println(v); //["english",'russian',"french","spanish"]

注解示例

//We define some lexical rules (starting with a "@")
@food <- burger.
@food <- tartare.


//Our rule: if "the food" word is found in a sentence, then we return a "meal" label 
meal <- "the", #food.

//We need a specific object to scan a sentence
annotator r;

//a sentence
string sentence="Here, the burger and the tartare are delicious."
vector v = r.parse(sentence); 

//Result: v =  [['meal',[10,16]],['meal',[25,32]]]
//It reads: two 'meal' were found at position 10-16 and position 25-32...

 

的码云指数为
超过 的项目
加载中

评论(15)

formever
formever
不行啊,这个国内竟然没有人给他写百科
rebeing
rebeing
像泰古
zhenruyan
zhenruyan
看起来可以啊
inuxor
inuxor
糖蘑菇?
d
dwcz
这是个语义化的工具吧,用于标注自然语言。
TGVvbmFyZA
TGVvbmFyZA
好吧 竟然是Naver的產品
醒着做夢
醒着做夢
哈塞kill
W
WindSpeed
居然是韩国人搞的语言
王重八
王重八
理解为什么有英语系的程序员反感示例里出现汉语了?出现看不懂的韩语我也不爽啊
Doeeking
Doeeking
南朝鲜开发的语言?
Doeeking
Doeeking
@红薯 手机APP没有删除评论功能,web页面没有@功能,what'

暂无资讯

暂无问答

暂无博客

返回顶部
顶部