Tamgu 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Tamgu 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Tamgu 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 BSD-3-Clause
开发语言 C/C++ 查看源码 »
操作系统 跨平台
软件类型 开源软件
所属分类 其他
开源组织
地区 不详
投 递 者 h4cd
适用人群 未知
收录时间 2019-09-19

软件简介

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...

 

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击加入讨论🔥(19) 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
19 评论
30 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部