No description
Find a file
2025-06-05 19:06:56 +08:00
src 删除:=:> 2025-06-05 19:06:56 +08:00
.gitignore Initial commit 2025-06-01 01:29:49 +08:00
LICENSE Initial commit 2025-06-01 01:29:49 +08:00
README.md Update README.md 2025-06-05 19:06:03 +08:00
tang.nimble Create tang.nimble 2025-06-01 02:00:17 +08:00

tang-nim🔥 The elegant sugar in nim lang.

tang is a library that gives you with convenient grammar sugar, especially in the for loop.

Examples

import tang
import threadpool

x<-1..10: #等价 for x in 1..10:
  discard
(x,y)<-[(1,2),(3,4),(5,6)]:
  discard
(x,y)<-(1..3,4..6):#等价 for x in 1..3:for y in 4..6:
  discard
x<-1..10<-3.step: #等价 for x in countup(1,10,3):
  discard         #等价 step(3,x<-1..10,:discard)


var list=newSeq[int]()
list<-1 #等价 add(list,1)
list<-2<-3<-4 #等价 add(list,1)...add(list,4)
<-list: #等价 add(list,5);add(list,6)
  5
  6
<-add list:#batch 简化写法
  7
  8
batch fn add list:
  9
  10
echo list  #@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

x<-1..10<-parallel:#<-用于扩展属性,可自行扩展
  discard          #等于 parallel x<-1..10:discard
x<-1..10<~int:#<~可判断x类型
  discard

if (x=:1)==1:#x=:1与python的海象操作符类似
  discard

#fn提供函数式写法
fn echo 1 2 3 4 5 #等价 echo(1,2,3,4,5)