Language Decoded
Collection
5 items • Updated
filename stringlengths 25 120 | content stringlengths 30 1.63M | extension stringclasses 15
values | source stringclasses 5
values | license stringclasses 3
values | quality_tier stringclasses 4
values | sha256 stringlengths 64 64 | byte_size int64 40 1.64M | total_lines int64 2 56.6k | cjk_ratio float64 0 1 | has_cjk bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|
000000_mulan__00000_MulanRevive__mulan-rework__确认语法说明完整.ul | using re
源数据 = open("文档/语法说明.md", 'rt', encoding="utf-8")
匹配 = re.search(3"`" + "\n(.*)\n" + 3"`", 源数据.read(), re.DOTALL)
文档各行 = 匹配 ? 匹配.group(1).split("\n") : []
文档规则 = []
for 行 in 文档各行 {
if re.match("^\s*$", 行) {
continue
}
字段 = 行.split(" : ")
if #字段 > 1 {
成分全文 = 字段[-1]
}
字段 = 行.split("| ")
if... | .ul | mulan | MIT | A | 9b01ee9c34532b67a81a42be136b6b04ae880662df4b4f6b283baba738cd6111 | 1,530 | 53 | 0.454369 | true |
000001_mulan__00001_MulanRevive__mulan-rework__善后.ul | try {} finally {}
/*
逆向里代码如下,出现的问题就是语法为try_stmt : TRY block final_stmt时try_stmt处理就会把handlers设置成block,其实就是语法出错了
因为要保持与原语言一致,所以我们的程序也不能增加实现,比如在加上try_stmt函数中如果len(p)为2时handlers设置为[]这样就可以正确处理
@pg_.production('try_stmt : TRY block catch_stmts')
def try_stmt(self, p):
return ast.Try(body=(p[1]),
han... | .ul | mulan | MIT | B | 82db27ecade8089024fb737d3227e6732303511cba2ffcc77db4891f70a532d5 | 1,018 | 21 | 0.195358 | true |
000002_mulan__00002_MulanRevive__mulan-rework__空匿名函数.ul | b = () -> 2
print(b())
/*
如出错将 /木兰/分析器/语法分析器.py `def lambda形参(self, 片段):` L762
if len(片段) == 2: # L775
# return self.形参列表()
return 语法树.新节点(语法.形参列表, 参数=[], 片段=片段)
*/ | .ul | mulan | MIT | A | 6017caa864a2e00cdc6869c0596ea088459d02fac6bee8aaf3672b3fbe1bd9b3 | 281 | 8 | 0.482759 | true |
000003_mulan__00003_MulanRevive__mulan-rework__顺便处理各表达式前缀.ul | try a,b=c {}
/*
原语言报错如下:
try a,b=c {}
ValueError: expression must have Store context but has Load instead
讲一下这句报错要表达的意思,
try a,b=c {} 的语法树如下:
Module(body=[With(items=[withitem(context_expr=Name(id='c', ctx=Load(), lineno=1, col_offset=9),
ptional_vars=Tuple(elts=[Name(id='a', ctx=Load(), lineno=1, col_offset=5), Name(i... | .ul | mulan | MIT | B | 6294aee44704ca9903eb0d3bc06273edc7d8478a026de48567e6890cd56784cd | 641 | 13 | 0.153846 | true |
000004_mulan__00004_MulanRevive__mulan-rework__字符串.ul | /* 测试 */
a = '测试'
str(time_diff) | .ul | mulan | MIT | B | e34465d382811d417d0ba09caf8a281e4ea82666ba27a8dd35d51b0ec120dd03 | 40 | 3 | 0.25 | true |
000005_mulan__00005_MulanRevive__mulan-rework__ExtSlice_待解决.ul |
/*
下方注释的代码当前木兰语法分析报错:
文件 "测试/unittest/源码生成/木兰到Python\ExtSlice.ul", 第1行, 第4列, 没认出这个词 ","
a[1?, 2]
*/
/*
a[1, 2]
a[1, 2, 3]
a[1, 2, 3, 4]
*/
| .ul | mulan | MIT | A | 8f457f7f277dd1b7ec26949d4467c2a25fa6adcbade11a4de1221c09541a4733 | 219 | 12 | 0.58209 | true |
000006_mulan__00006_MulanRevive__mulan-rework__ImportFrom_待解决.ul | // using b in .. // 此语句当前的木兰语法分析报错:
/*
文件 "测试/unittest/源码生成/木兰到Python\ImportFrom.ul", 第4行, 第12列, 没认出这个词 ".."
using b in ?..
*/
| .ul | mulan | MIT | A | 4c3d1e84ef26d1a50c69ec42de4312a4600f7cff62db33942521ffb34d79d5e2 | 201 | 5 | 0.461538 | true |
000007_mulan__00007_MulanRevive__mulan-rework__signature.ul | /*
原始木兰不能执行该测试用例:
$ C:\ulang-0.2.2.exe --dump-python .\源码生成\函数\变长指名参数.ul
SyntaxError: File ".\源码生成\函数\变长指名参数.ul", line 1:8, unexpected token "*"
func a(**kwargs) {
^
*/
func a(**kwargs) {
print(kwargs)
}
func b(*args) {
print(args)
}
a(k1="v1", k2="v2")
b(3, 4)
a(**{a: 1, b: 2})
b(*(3, 4))
| .ul | mulan | MIT | B | 9b44aa443007f2c0fb4cbd18129b50629fd6f9dce88bbd282dae3de637c71c66 | 386 | 21 | 0.24359 | true |
000008_mulan__00008_MulanRevive__mulan-rework__冒泡.ul |
func 冒泡(数列) {
换过 = true
while 换过 {
换过 = false
for i in range(0, len(数列) - 1) {
前项 = 数列[i]
后项 = 数列[i + 1]
if (前项 > 后项) {
数列[i], 数列[i + 1] = tuple(后项, 前项)
换过 = true
}
}
}
}
打乱数列 = [5, 2, 1, 8, 4]
冒泡(打乱数列)
println(打乱数列) | .ul | mulan | MIT | A | 0b6325b4c92a3c9fc3a80bdd7cc41e15c7a58a9241ca99ab71236c81a50835f5 | 371 | 18 | 0.470588 | true |
000009_mulan__00009_MulanRevive__mulan-rework__插入.ul |
func 插入排序(数列) {
for i in range(1, len(数列)) {
挑出 = 数列[i]
位置 = i - 1
while ((位置 >= 0) and (数列[位置] > 挑出)) {
数列[位置 + 1] = 数列[位置]
位置 -= 1
}
数列[位置 + 1] = 挑出
}
}
乱序数列 = [5, 2, 1, 8, 4]
插入排序(乱序数列)
println(乱序数列) | .ul | mulan | MIT | A | 5bad0c12f56579c4783d83fc7033e8e885eb55c89e43f36969eeae0bff3dd80d | 347 | 15 | 0.606742 | true |
000010_mulan__00010_MulanRevive__mulan-rework__猜数字.ul | using sys, cmd
using randrange in random
type 猜数字 : cmd.Cmd {
{
intro, prompt = tuple('我想了个 100 之内的数,猜猜是几?', '请猜吧: ')
想的 = randrange(1000) / 10
}
func $default(行) {
try {
数 = int(行)
}
catch 例外 : ValueError {
println(行 + ' 不是数,请再试')
return
}
$比较(数)
}
func $比较(... | .ul | mulan | MIT | B | 1afe37b738e35900239e53241ac164d45a860d0d0641605f4e19cb5261a793a8 | 567 | 30 | 0.282927 | true |
000011_mulan__00011_MulanRevive__mulan-rework__文件.ul | f = open('测试/函数/API/测试.txt', 'rt')
内容 = f.read()
f.close()
print(内容) | .ul | mulan | MIT | B | 4851f094663ab9146a279ec3b71e6839af16ae616c59daeb7ad057c1354c820a | 88 | 4 | 0.25641 | true |
000012_mulan__00012_MulanRevive__mulan-rework__map.ul | func 平方(n) {
return n*n
}
print(list(map(平方, [1,2,3]))) | .ul | mulan | MIT | B | b3b31667176a336f3a91cda3e854b03f6cb45dc63caf25089ad91420e5e81dfa | 67 | 4 | 0.137931 | true |
000013_mulan__00013_MulanRevive__mulan-rework__匿名函数.ul | print(list(filter(func (n) { return n>0 }, [1,-1])))
print(list(filter(n -> n>0, [1,-1])))
print(list(filter(n -> {
平方 = n*n
return 平方>5
}, [1,3])))
print(list(filter(
边长 -> { 面积 = 边长 * 边长; return 面积 > 5 },
[1,3]
)))
print(list(map(
func (边长) { 面积 = 边长 * 边长; return 面积 },
[1, 2]
)))
print(func (长, 宽) {
面积 ... | .ul | mulan | MIT | A | 15ec0f49a4b7d8737deb83796200ec9edd1574c619e3297ef3b46004235bc455 | 967 | 38 | 0.340237 | true |
000014_mulan__00014_MulanRevive__mulan-rework__指定返回类型.ul | type Person {
{
name = "小白"
}
func $__init__(name) {
self.name = name
}
}
func shout(id): Person {
return Person(id)
}
print(shout("Mulan1").name) | .ul | mulan | MIT | C | c03fec8ed0d616c46b2c7e87b1dd51c9c36662e36bfb04621b5057529619325c | 189 | 15 | 0.022222 | true |
000015_mulan__00015_MulanRevive__mulan-rework__若干形参.ul | func 若干形参(...) {
for 参数 : ... {
print(typeof(参数))
}
}
type Test {
{}
}
若干形参(1, 2.3, '3', Test())
func 回复(...) {
print(...)
}
回复(1, 2, 3)
单个若干参数 = (...) -> typeof(...)
print(单个若干参数('string'))
多个若干参数 = (...) -> max(...)
print(多个若干参数(3, 1, 2))
func 求和(...){
和值 = 0
for 值 in ... {
和值 ... | .ul | mulan | MIT | A | a86e9b94e01811b42b62184ac56c35791cd15a6df1bf6bcfaa91eef143179120 | 635 | 32 | 0.351648 | true |
000016_mulan__00016_MulanRevive__mulan-rework__过滤.ul | func a() {
func 大数(n) {
return n>5
}
return 大数
}
print(list(filter(a(), [1,10]))) | .ul | mulan | MIT | B | 03337ab509ff662ea36de5d3e7c27be01bc9a54f5302f8c0655dd2b614bdf95e | 109 | 7 | 0.093023 | true |
000017_mulan__00017_MulanRevive__mulan-rework__返回多值.ul | func echo() {
return 1, 2
}
多值 = echo()
print(多值[0])
print(多值[1]) | .ul | mulan | MIT | B | 00e57b8ad867dcb6d5f2131f1f9307ab4ec7c518f53a6fe4bcc4b8d4dd5980a0 | 81 | 6 | 0.176471 | true |
000018_mulan__00018_MulanRevive__mulan-rework__双引号.ul | print("ok")
print("\n")
print("\t")
print("\\\")
print("\"")
print("\\\"+"n")
func print2(a, b) {
print(a)
}
print2("a","b")
源数据文件 = open("测试/字符串/空行.txt", 'rt', -1, "utf-8")
内容 = 源数据文件.read()
源数据文件.close()
print(内容 == "\n")
源数据文件 = open("测试/字符串/制表符.txt", 'rt', -1, "utf-8")
内容 = 源数据文件.read()
源数据文件.close()
print(内容 =... | .ul | mulan | MIT | A | a8b11983794e6e841e157616cc4923875c880fc9dc400721de98b033d30ae5b1 | 446 | 19 | 0.30814 | true |
000019_mulan__00019_MulanRevive__mulan-rework__相关方法.ul | print("你好".find('好'))
for 字 in "hi" {
print(字)
}
using re
print(re.findall('\bfish', 'fish 1fish'))
| .ul | mulan | MIT | B | f18e1c624c7ef0ce603da2cfa7e5a552811a02462a8142155974e5d453b96064 | 112 | 6 | 0.083333 | true |
000020_mulan__00020_MulanRevive__mulan-rework__四百药.ul | using re
源数据 = open("测试/实用/中医/四百药.txt", 'rt', encoding="utf-8")
所有行 = 源数据.read().split("\n")
源数据.close()
药名 = []
for 行 in 所有行 {
匹配 = re.match("\d+\.(.*)[(\s]", 行)
if 匹配 {
药名.append(匹配.group(1))
continue
}
匹配 = re.match("\d+\.(.*)$", 行)
if 匹配 {
药名.append(匹配.group(1))
}
}
去重 = set(药名)
printl... | .ul | mulan | MIT | A | b2a69349f7b31277703995150acd7ad2e4167ad0ebc8d4e4169808e5e61f73e8 | 451 | 25 | 0.313953 | true |
000021_mulan__00021_MulanRevive__mulan-rework__分词.ul | using jieba
词表 = jieba.cut("谁也不用奇怪也别问为什么呀")
for 词 in 词表 {
println(词)
} | .ul | mulan | MIT | A | 35a9390ce539e60f1a2dede0a0ddc5c9ea31eb4aca3842083ac61f0088e34034 | 113 | 6 | 0.387755 | true |
000022_mulan__00022_MulanRevive__mulan-rework__取形声字.ul | using 字典 in chinese_characters_words
using * in chinese_regular_expression.规律
using json, re
常用字数据 = open('测试/实用/字/常用字拆字.json', 'r', encoding="utf-8")
拆字 = json.load(常用字数据)
常用字数据.close()
func 字音(字) {
信息 = 字典.查单字(字)
return 信息 ? 信息['拼音'] : nil
}
func 去音调(拼音) {
拼音 = re.sub(某字('āáǎà').表达(), 'a', 拼音)
拼音 = re.sub(... | .ul | mulan | MIT | A | b0fe16cc58a41e5cdf658f4d158b4d40637ef5aa6a729209bc3cef21770d11af | 1,306 | 49 | 0.476744 | true |
000023_mulan__00023_MulanRevive__mulan-rework__常用字拆分.ul | using 为常用字 in 测试.实用.通用.库_常用字
using json
// 不包含常用字, 比如"广"
// ⻖和⻏分别为左/右耳朵旁
// 形近码异问题: 辶⻌不同!
一笔 = "乚"
二笔 = "刂冫匚𠆢亠⺆勹亻辶⻌廴冖讠⻖⻏"
三笔 = "氵彡丬口囗扌忄饣彳宀艹纟犭彐"
四笔 = "灬歹𤣩𠃜龵⺼攵"
五笔 = "疒𢀖矢衤钅⺲皿覀缶耒糸𧾷癶"
常用部首 = 一笔 + 二笔 + 三笔 + 四笔 + 五笔
// 数据中, 部首 礻为"示"
// 数据来源:http://git.chise.org/gitweb/?p=chise/ids.git;a=blob_plain;f=IDS-UCS-Basic.txt;... | .ul | mulan | MIT | A | 40c3b8b3d154c6a7cd580f8dcf952f1a0c0046cc82079d1107e60b5621558b37 | 2,032 | 67 | 0.511346 | true |
000024_mulan__00024_MulanRevive__mulan-rework__扩展拆字游戏.ul | using json
部分1 = "又寸土工斤木白旦各莫十分丁户少合青鸟包羊月古"
部分2 = "亻讠木又火口目⺼扌日氵𧾷宀艹广门辶"
// 待加:广门辶
// 待定: 纟钅
常用字数据 = open('测试/实用/字/常用字拆字.json', 'r', encoding="utf-8")
拆字 = json.load(常用字数据)
常用字数据.close()
func 搜索偏旁(偏旁) {
字数 = 0
所有字 = []
for 字 in 拆字 {
字型, 部分 = 拆字[字]['字型'], 拆字[字]['部分']
if 部分[0] == 偏旁 or 部分[1] == 偏旁 {
字... | .ul | mulan | MIT | A | c1a09dfcc55730f291ec611878de5cd7a9eafcf713f8194b14602ca8106b74e3 | 1,570 | 59 | 0.599562 | true |
000025_mulan__00025_MulanRevive__mulan-rework__凑十法.ul | 拆分 = {
2 : [[1, 1]],
3 : [[1, 2]],
4 : [[1, 3], [2, 2]],
5 : [[1, 4], [2, 3]],
6 : [[1, 5], [2, 4], [3, 3]],
7 : [[1, 6], [2, 5], [3, 4]],
8 : [[1, 7], [2, 6], [3, 5], [4, 4]],
9 : [[1, 8], [2, 7], [3, 6], [4, 5]],
10 : [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]
}
func 取剩余(整体, 部分) {
for 两部分 in 拆分[整体]... | .ul | mulan | MIT | A | 4b9944f0c757bf4ae8e02a990803d22af2a17d55aeb8238f6a5b4922bf2e3838 | 663 | 29 | 0.607143 | true |
000026_mulan__00026_MulanRevive__mulan-rework__聊天演示.ul | /*
#!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | .ul | mulan | MIT | B | f28f5ef8bb511b1fed2ab55b15d352b1b843de88fc56367a59687394d1c9c9b2 | 3,233 | 124 | 0.157059 | true |
000027_mulan__00027_MulanRevive__mulan-rework__简单.ul | using SimpleHTTPRequestHandler in http.server
using socketserver
端口 = 8080
try 服务=socketserver.TCPServer(tuple("", 端口), SimpleHTTPRequestHandler) {
println("请访问:http://localhost:8080/")
服务.serve_forever()
}
/* 参考: https://www.afternerd.com/blog/python-http-server/ */
| .ul | mulan | MIT | B | fdee63b71cf6b2bfc57569766adeffa9bc7c4298894e6a12444238f114d694e1 | 307 | 11 | 0.071066 | true |
000028_mulan__00028_MulanRevive__mulan-rework__中.ul | using * in 测试.实用.棋.井字.棋盘
using * in 测试.实用.棋.井字.棋局
格数 = 3
棋盘 = 棋盘图样(格数)
状况 = 棋盘状况(格数)
loop {
状况.落子(棋盘.鼠标位置所在格()) if 棋盘.取事件() == 棋盘事件.鼠标按键
棋盘.画棋盘()
棋盘.画棋子(状况.所有子)
if 状况.结束() {
棋盘.宣布结果(状况.取结语())
}
棋盘.更新()
}
| .ul | mulan | MIT | A | 2bf69e34c4da3dabde448df5dfd4fd04ebc6d39f3b724c0981efddad83d0387e | 414 | 16 | 0.813559 | true |
000029_mulan__00029_MulanRevive__mulan-rework__棋局.ul | using Enum in enum
using 相等 in 测试.实用.通用.测试相关
using * in 测试.实用.棋.井字.模型
/* 不依赖 pygame, 易于测试 */
赢了 = 3
结语 = {
状态.X胜: "X 赢了!",
状态.O胜: "O 赢了!",
状态.平局: "平了!"
}
type 步 {
func $步(横, 纵, 棋手) {
$横, $纵, $棋手 = 横, 纵, 棋手
}
func $棋手为X {
return $棋手 == 棋手.X
}
operator == (另一子) {
return $横 == 另一子.横 and ... | .ul | mulan | MIT | A | eda3a77ee765cda834050449e4998a7c595e3cbaf636a17579076e3e81f8ab47 | 2,727 | 109 | 0.505632 | true |
000030_mulan__00030_MulanRevive__mulan-rework__棋盘.ul | using Enum in enum
using pygame
type 棋盘事件 : Enum {
{
退出 = 1
鼠标按键 = 2
}
}
边框 = 60
格子尺寸 = 100
半格 = 格子尺寸 / 2
线宽 = 5
// 参考: https://pygame-zero.readthedocs.io/en/latest/colors_ref.html
// https://github.com/pygame/pygame/blob/master/src_py/colordict.py
背景色 = pygame.Color("darkorange")
红色 = pygame.Color("red... | .ul | mulan | MIT | A | 246097449a41d104fbde0c83c6aeb1d74b12294152e75e158b0be9c7c8fd70f5 | 2,785 | 103 | 0.366375 | true |
000031_mulan__00031_MulanRevive__mulan-rework__模型.ul | using Enum in enum
type 棋手 : Enum {
{
X = 1
O = 2
}
}
type 状态 : Enum {
{
对弈 = 1
X胜 = 2
O胜 = 3
平局 = 4
}
}
| .ul | mulan | MIT | B | a74e01680d3a320aa06925d5505ce34b1d0a52e2ec17e03e2bca477a14af108d | 159 | 17 | 0.222222 | true |
000032_mulan__00032_MulanRevive__mulan-rework__中.ul | using 点 in 测试.实用.规划.点
using 范围, 全区, 部分区域, 二乘二, 三格, 长折, 短折, 一字 in 测试.实用.规划.范围
using 占地 in 测试.实用.规划.占地
using 相等 in 测试.实用.通用.测试相关
// 需记录占据情况
// TODO: 指定形参的类型
func 各种朝向(初始形状){
所有形状 = [初始形状]
转后形状 = 初始形状
for 旋转次数 in 1..3 {
转后形状 = 转后形状.顺时针转90度()
if 转后形状 != 初始形状 {
所有形状.append(转后形状)
} else {
bre... | .ul | mulan | MIT | A | 590aa637a82c78f562f339721a6515374aa9a19728b7c7cbd4599b7d7e31d549 | 2,497 | 83 | 0.742938 | true |
000033_mulan__00033_MulanRevive__mulan-rework__占地.ul | using 范围 in 测试.实用.规划.范围
using 点 in 测试.实用.规划.点
using 相等 in 测试.实用.通用.测试相关
type 占地 {
func $占地(某范围, 原点) {
$原点 = 原点
横偏移 = 原点.横
纵偏移 = 原点.纵
$范围 = 范围(list(map(某点 -> [某点.横 + 横偏移, 某点.纵 + 纵偏移], 某范围.所有点)))
}
func $__repr__ {
return "中心为`$原点`的`$范围`"
}
}
相等(范围([
[1, 2],
[1, 1], [2, 1]
]), 占地... | .ul | mulan | MIT | A | 0d0d3a76f2a3ba35e462fa0ce6aded3e4c0ed2f5afca882499528b5ce1b410d3 | 582 | 25 | 0.666667 | true |
000034_mulan__00034_MulanRevive__mulan-rework__点.ul | using 相等 in 测试.实用.通用.测试相关
type 点 {
func $点(横, 纵) {
$横, $纵 = 横, 纵
}
operator == (另一点) {
return $横 == 另一点.横 and $纵 == 另一点.纵
}
func __repr__(self) {
return "(`$横`, `$纵`)"
}
}
相等(0, 点(0, 1).横, "点横坐标")
相等(1, 点(0, 1).纵, "点纵坐标")
相等(true, 点(0, 1) == 点(0, 1), "点相等")
相等(false, 点(1, 1... | .ul | mulan | MIT | A | efafe2be1919ad3811f20e552323bbc78ff0af0de658a9a4e0064304c89da7bc | 473 | 20 | 0.528 | true |
000035_mulan__00035_MulanRevive__mulan-rework__范围.ul | using 点 in 测试.实用.规划.点
using 相等 in 测试.实用.通用.测试相关
using 按某项生成映射 in 测试.实用.通用.结构
type 范围 {
func $范围(所有坐标) {
self.所有点 = list(map(坐标数组 -> 点(坐标数组[0], 坐标数组[1]), 所有坐标))
}
func 创建方阵(长, 宽) {
所有点 = []
for 纵坐标 in (宽 - 1)..0 by -1 {
for 横坐标 in 0..<长 {
所有点.append([横坐标, 纵坐标])
}
}
return ... | .ul | mulan | MIT | A | 923cd2a762b9a7a7f0b8a60987e9cfb3c4105c3eff8e27b50e457f3105778fc5 | 2,917 | 111 | 0.5953 | true |
000036_mulan__00036_MulanRevive__mulan-rework__库_常用字.ul | 字表 = {
"1": "一乙",
"2": "二十丁厂七卜八人入儿九几了乃刀力又",
"3": "三干于亏士土工才下寸丈大与万上小口山巾千乞川亿个么久勺丸夕凡及广亡门义之尸已弓己卫子也女飞刃习叉马乡",
"4": "丰王井开夫天元无云专扎艺木五支厅不太犬区历友尤匹车巨牙屯比互切瓦止少日中贝内水冈见手午牛毛气升长仁什片仆化仇币仍仅斤爪反介父从今凶分乏公仓月氏勿风欠丹匀乌勾凤六文方火为斗忆计订户认心尺引丑巴孔队办以允予劝双书幻",
"5": "玉刊末未示击打巧正扑扒功扔去甘世古节本术可丙左厉石右布龙平灭轧东卡北占业旧帅归目旦且叮叶甲申号电田由只央史兄叼叫叨另叹四生失禾丘付仗代仙们仪白仔他斥瓜乎丛令用甩印乐句匆册犯外... | .ul | mulan | MIT | A | 41602bd28d538e920a25cf4a4005a4c1100c44532c971fc69eb4bc5286649f3e | 8,017 | 39 | 0.985266 | true |
000037_mulan__00037_MulanRevive__mulan-rework__测试相关.ul |
func 相等(目标, 实际, 信息) {
if 实际 != 目标 {
println("`信息`出错。目标: `目标`, 但实际为: `实际`")
}
}
| .ul | mulan | MIT | A | ac8b1ce2aafe9f536a16498af858f249d7afd3e0b1de00293fc1d0e48376e0a6 | 142 | 6 | 0.675 | true |
000038_mulan__00038_MulanRevive__mulan-rework__结构.ul |
func 按某项生成映射(列表, 生成键, 生成值) {
点表 = {:}
for 项 in 列表 {
键 = 生成键(项)
值 = 生成值(项)
if 点表.get(键) {
点表[键].append(值)
} else {
点表[键] = [值]
}
}
return 点表
} | .ul | mulan | MIT | A | 00f85282e7a78fa690d1e7f7548c74a01733cd70a25bb559d70afbfa5dc9e09c | 294 | 14 | 0.589041 | true |
000039_mulan__00039_MulanRevive__mulan-rework__引用木兰多个.ul | using 测试.包.module_ul, 测试引用2
测试.包.module_ul.talk()
测试引用2.唱()
| .ul | mulan | MIT | A | cf203a3f3d9b20a2397201c81e0d76a6f25430f65cb965d57d725af5d3a65318 | 90 | 3 | 0.375 | true |
000040_mulan__00040_MulanRevive__mulan-rework__引用本地包内木兰.ul | using 测试.包.module_ul
测试.包.module_ul.talk() | .ul | mulan | MIT | B | 3542aa7eaa1ac5593829c5b89714450233b7bfbc4625462e36564b649533e177 | 54 | 2 | 0.193548 | true |
000041_mulan__00041_MulanRevive__mulan-rework__引用本地包内木兰某内容.ul | using talk in 测试.包.module_ul
talk() | .ul | mulan | MIT | B | d47a0859a7a0d2b4e174cd6a2fabb01fbcbaf28934b7043059c45dfe4c567d23 | 41 | 2 | 0.115385 | true |
000042_mulan__00042_MulanRevive__mulan-rework__取毫秒.ul | using time
毫秒 = time.time() * 1000
print(毫秒) | .ul | mulan | MIT | B | a69e8e0bf591dbd08dbb7f4ee3d99a59589ceb77b33f36b99fb06c0825bbb4a8 | 53 | 4 | 0.153846 | true |
000043_mulan__00043_MulanRevive__mulan-rework__命令行.ul | using Cmd in cmd; using randrange in random
type 猜数字 : Cmd {
{
intro, prompt = "木兰想了个 100 之内的数,猜是几?", "\n猜猜吧: "
想的 = randrange(1000) / 10; 历史 = []
}
func $default(行) {
try { 数 = int(行) }
catch 例外 : ValueError { println("`行` 不是数,请再试"); return }
$历史.append(数); $比较(数)
}
func $比较(数) {
{... | .ul | mulan | MIT | A | 4af407000ae5547969525610cdd0e3f8bc2d6b5d38704f817885837840b66cc9 | 771 | 27 | 0.334545 | true |
000044_mulan__00044_MulanRevive__mulan-rework__断言.ul | assert(2>1, 'pass')
assert(2<1, 'fail')
/*
(..•˘_˘•..) fail
见第2行:assert(2<1, 'fail')
*/ | .ul | mulan | MIT | B | 1585e6678fdbaee1799fb9a920df3f4054011fa65a37587e418687d75b7e9665 | 101 | 6 | 0.105263 | true |
000045_mulan__00045_MulanRevive__mulan-rework__草蟒_图快.ul | using * in 图快
窗口 = 主窗口类()
窗口.标题('图形应用程序')
窗口.尺寸('500x300+600+300')
func 登录(){
登录窗口 = 顶级窗口类(窗口)
登录窗口.标题('请登录...')
登录窗口.尺寸('200x200+750+350')
}
登录按钮 = 按钮类(文本='登录', 命令=登录)
登录按钮.位置布局(相对x=0.5, 相对y=0.5)
窗口.主循环() | .ul | mulan | MIT | A | 91531b538449c57cfae2cc62468a00409d15d29f81bcf49f917337be9263ce8f | 385 | 16 | 0.845361 | true |
000046_mulan__00046_MulanRevive__mulan-rework__草蟒_海龟.ul | /* Python 库“草蟒”: grasspy-modules 已失效,此例程不再运行 */
using * in 海龟
颜色("黄色", "红色")
开始填充()
for 转角 in 0..4 {
前进(200); 右转(144)
}
结束填充()
主循环()
| .ul | mulan | MIT | A | f8074e93ffda9e4f78c12b597dbb911e35a57a25adb30a511de0835a1bc22b14 | 220 | 10 | 0.555556 | true |
000047_mulan__00047_MulanRevive__mulan-rework__列表取值.ul | 列表=[1,2,3]
print(列表[1])
列表[1] = 4
print(列表[1])
列表.append(5)
print(列表[3])
print(列表[0:2])
print(列表[2:])
print(列表[:2])
print(列表[:]) | .ul | mulan | MIT | A | dbc2969e8993da422f97bc7ecfc30165ebe20ed09a1d093a94f9e56563ad9ae1 | 168 | 10 | 0.327869 | true |
000048_mulan__00048_MulanRevive__mulan-rework__枚举.ul | using Enum in enum
type 颜色 : Enum {
{
红 = 1
黄 = 2
}
}
for 某色 in 颜色 {
print(某色.value)
} | .ul | mulan | MIT | B | 447949ff636484ebd7592000e2fdb89b8e4aae3e59785e3e7fbb8f9fdf55c8f2 | 120 | 10 | 0.208333 | true |
000049_mulan__00049_MulanRevive__mulan-rework__lambda_1参.ul | print((n -> n + 1)(2))
/* 没认出这个词 "(" */ | .ul | mulan | MIT | A | 83d091ad864de45272b966c3cbf33f8dbbd4bb87d7cc173629bee888c0566f14 | 51 | 2 | 0.461538 | true |
000050_mulan__00050_MulanRevive__mulan-rework__lambda_2参.ul | print(list(map((x,y) -> x + y, [(1,2)])))
/* 没认出这个词 "," */ | .ul | mulan | MIT | B | d52bb3c1ce6bb9078b2fa20a2e59e979fc0d5550b405a5875878558239a1bf54 | 70 | 2 | 0.272727 | true |
000051_mulan__00051_MulanRevive__mulan-rework__lambda_无参.ul | func 平方(n) {
return func {
print(n*n)
}
}
print(平方(2)())
/* TypeError: required field "args" missing from arguments */ | .ul | mulan | MIT | B | e42d85e3379778042df611c37ab0e36e714eccecd9278b06b6602bb66376182d | 134 | 7 | 0.051948 | true |
000052_mulan__00052_MulanRevive__mulan-rework__中文标识符.ul | func 过(年) {
print(年 + 1)
}
过(2019) | .ul | mulan | MIT | A | 65908f3db380d5066bcbc2fc036801ca363c58e458f89d1be601fddbcf24ec21 | 44 | 4 | 0.307692 | true |
000053_mulan__00053_MulanRevive__mulan-rework__注释块.ul | /* 测试 1 */print(2)
/*
测试
2
*/
// 测试 3
print(3)
| .ul | mulan | MIT | A | 4275d13849a73a01a7435f0b028a20dfc296ba2dd0ef7579b30d2848470a04fe | 59 | 7 | 0.375 | true |
000054_mulan__00054_MulanRevive__mulan-rework__冒泡.ul | /* 参考: https://stackabuse.com/sorting-algorithms-in-python/ */
func 冒泡(数列) {
换过 = true
while 换过 {
换过 = false
for i in 0..len(数列) - 2 {
前项 = 数列[i]
后项 = 数列[i + 1]
if 前项 > 后项 {
数列[i], 数列[i + 1] = 后项, 前项
换过 = true
}
}
}
}
打乱数列 = [5, 2, 1, 8, 4]
冒泡(打乱数列)
print(打乱数列) | .ul | mulan | MIT | A | 840982d61bd20a34751d0b58390d1c30dbd5cbfbe92de8cac735e10c06c34cdd | 420 | 19 | 0.37037 | true |
000055_mulan__00055_MulanRevive__mulan-rework__快速.ul | func 分区(数列, 下界, 上界) {
中值 = 数列[上界] // 中值可以取任意一个位置的
前位 = 下界
for 后位 in 下界..上界 {
if 数列[后位] < 中值 {
数列[前位], 数列[后位] = 数列[后位], 数列[前位]
前位 += 1
}
}
数列[前位], 数列[上界] = 数列[上界], 数列[前位]
return 前位
}
func 快速排序(数列) {
func 递归(各项, 下界, 上界) {
if 下界 < 上界 {
中位 = 分区(各项, 下界, 上界)
递归(各项, 下界, 中位 - ... | .ul | mulan | MIT | A | 2484d0ba4c1ac12a80a5c4d0970dfdd8db50a1f3207dff2059ff05ce8de7ae91 | 721 | 28 | 0.804469 | true |
000056_mulan__00056_MulanRevive__mulan-rework__插入.ul | func 插入(数列) {
for i in 1..<len(数列) {
挑出 = 数列[i]
位置 = i - 1
while 位置 >= 0 and 数列[位置] > 挑出 {
数列[位置 + 1] = 数列[位置]
位置 -= 1
}
数列[位置 + 1] = 挑出
}
}
打乱数列 = [5, 2, 1, 8, 4]
插入(打乱数列)
print(打乱数列)
| .ul | mulan | MIT | A | 57a5a4f4eb5d49baec8b1a9191020882a967a4a16d3f1c5e8b96f97e93536d9e | 322 | 15 | 0.641026 | true |
000057_mulan__00057_MulanRevive__mulan-rework__个体属性.ul | type Person {
func $Person(name) {
self.name = name
$名字 = name
$type = name
}
}
mulan = Person(1)
print(mulan.name)
print(mulan.名字)
print(mulan.__getattribute__('type'))
/* 等价于:
for attribute, value in mulan.__dict__.items() {
print(attribute, '=', value) if attribute == 'type'
}
*/
| .ul | mulan | MIT | C | db358bc3aa329cab5aa497df4d40a01e68ec5eacc3cadf2f95fdf5e120e5ce08 | 335 | 16 | 0.043478 | true |
000058_mulan__00058_MulanRevive__mulan-rework__定义方法self.ul | type Person {
func getAge(self) {
return 1
}
func $自身() {
return $
}
}
mulan = Person()
print(mulan.getAge())
print(mulan.自身().getAge()) | .ul | mulan | MIT | C | f69842552501e17db94561cf46b4cb4cf50851582dbacd1008af0cdabb09fe6d | 176 | 11 | 0.045977 | true |
000059_mulan__00059_MulanRevive__mulan-rework__构造方法原始.ul | type Person {
{
name = "小白"
}func $__init__(name) {
self.name = name
}
}
mulan = Person("Mulan")
print(mulan.name) | .ul | mulan | MIT | C | 50e50c2f7e7e8ac4570980e17d2bcdbae24f932c07bff1cabe8f0d54570b8aea | 146 | 9 | 0.028571 | true |
000060_mulan__00060_MulanRevive__mulan-rework__继承.ul | type Animal {
func getName() {
return 1
}
}
type 当地 {
{}
}
type Person : Animal {
{}
}
type 当地人 : Person, 当地 {
{}
}
print(Person.getName())
/*
必须先定义 Animal
*/ | .ul | mulan | MIT | B | 907f0acdd44b1d98e7530e640cc67d259c5f37e7eb18d1776e163638387634a2 | 198 | 18 | 0.129032 | true |
000061_mulan__00061_MulanRevive__mulan-rework__乘.ul | print(2*3)
长 = 2
宽 = 3
print(3长 + 4 宽)
print(6/2(1+2))
正方形边长 = 2
print(4(正方形边长:int)) | .ul | mulan | MIT | A | 8e87f6c7e5ae099328be23bc3643b3bb339b5325139cae9c50e3cf0ed594c6a6 | 112 | 7 | 0.378378 | true |
000062_mulan__00062_MulanRevive__mulan-rework__综合.ul | func 累积(上限) {
数 = 1
和 = 0
while 1==1 and 2==2 or 3==3 {
if 数 <= 上限 {
和 = 和 + 数
数 = 数 + 1
continue
} elif 1!=2 {
break
} else {
break
}
}
return 和
}
print(累积(4)) | .ul | mulan | MIT | B | 0e9051c9afc88e101768cc5e310fd0a55015e29d80ca9bb0a52bade85b2d4519 | 250 | 17 | 0.242857 | true |
000063_mulan__00064_MulanRevive__mulan-rework__引用模块.ul | using * in 测试.错误处理.下标越界函数
a()
| .ul | mulan | MIT | A | a58f9c03a40a3529d616b277579489d7b264dff0aec096577629f977a877b99a | 55 | 3 | 0.6 | true |
000064_mulan__00065_MulanRevive__mulan-rework__引用问题模块.ul | using * in 测试.错误处理.无此变量
print(a)
| .ul | mulan | MIT | A | 86683235ade0c7db26f168106038d6ce2a92c822e0faee08f749bd373edaa353 | 54 | 3 | 0.434783 | true |
000065_mulan__00066_MulanRevive__mulan-rework__a.ul | using * in 测试.错误处理.循环引用.b
aa = bb
print("aa in a: " + aa) | .ul | mulan | MIT | B | 5ca980b2f082535f6c67146a6cff395cf82fef7ee08be2dfa441a18c7f65b0c1 | 78 | 4 | 0.294118 | true |
000066_mulan__00067_MulanRevive__mulan-rework__b.ul | using * in 测试.错误处理.循环引用.a
bb = aa
print("bb in b: " + bb) | .ul | mulan | MIT | B | c7cc1b027df95bf2ffff19792f158119b226a93ff4917f32bf65bb58a205a37e | 78 | 4 | 0.294118 | true |
000067_mulan__00068_MulanRevive__mulan-rework__未定义变量于多层函数.ul | func 加(数) {
return 数1 + 1
}
func 输出(数) {
print(数)
}
输出(加(2))
| .ul | mulan | MIT | A | 80cd8437a6e4b8bd5a29795c3f4d85b6de4172889e802469b5a638fab1fa724c | 85 | 7 | 0.344828 | true |
000068_mulan__00069_MulanRevive__mulan-rework__类型定义中使用本类型.ul | type Person {
{
name = "小白"
}
func $__init__(name) {
self.name = name
}
func newPerson(): Person {
return 0
}
}
| .ul | mulan | MIT | C | 7d2596200df82f2543e2d58df6af24d71fd493f036fbce798c2a9533203d4788 | 166 | 13 | 0.030769 | true |
000069_mulan__00070_MulanRevive__mulan-rework__自身.ul | type 长方 {
func $长方(长, 宽) {
$长 = 长
$宽 = 宽
}
func $面积() {
return $.长 * $宽
}
}
块 = 长方(3, 4)
print(块.面积())
| .ul | mulan | MIT | A | fc180af171f6bf457b3fffe1472de61e969604be6efa83f2a9ae1923b42cf196 | 164 | 12 | 0.465116 | true |
000070_mulan__00072_MulanRevive__mulan-rework__调用错误函数.ul | using a in 测试.错误处理.函数内不识变量
a()
| .ul | mulan | MIT | A | e96a1cbe0e73b66154980d12137a630614bc729f9e89714f0f8fbe89a61544c6 | 58 | 3 | 0.590909 | true |
000071_mulan__00074_python2008__mulan-rework__猜数字.ul | using sys, cmd
using 随机范围数 in 随机数
type 猜数字 : cmd.Cmd {
{
intro, prompt = tuple('我想了个 100 之内的数,猜猜是几?', '请猜吧: ')
想的 = 随机范围数(1000) / 10
}
func $default(行) {
try {
数 = int(行)
}
catch 例外 : ValueError {
println(行 + ' 不是数,请再试')
return
}
$比较(数)
}
func $比较(数) {
if... | .ul | mulan | MIT | A | 842b6d8d33e070c049ead4a247165202a7e9aade2a9ea40dceceab8ade0fda03 | 582 | 30 | 0.365979 | true |
000072_mulan__00075_python2008__mulan-rework__常用字拆分.ul | using 为常用字 in 测试.实用.通用.库_常用字
using json
// 不包含常用字, 比如"广"
// ⻖和⻏分别为左/右耳朵旁
// TODO: 问题: 辶⻌不同!
一笔 = "乚"
二笔 = "刂冫匚𠆢亠⺆勹亻辶⻌廴冖讠⻖⻏"
三笔 = "氵彡丬口囗扌忄饣彳宀艹纟犭彐"
四笔 = "灬歹𤣩𠃜龵⺼攵"
五笔 = "疒𢀖矢衤钅⺲皿覀缶耒糸𧾷癶"
常用部首 = 一笔 + 二笔 + 三笔 + 四笔 + 五笔
// 数据中, 部首 礻为"示"
// 数据来源:http://git.chise.org/gitweb/?p=chise/ids.git;a=blob_plain;f=IDS-UCS-Basic.tx... | .ul | mulan | MIT | A | 280daa9643ac00e5b4b7b9a2f87bfb85348793567e9721589c8e9bd81a1d370f | 2,032 | 67 | 0.502256 | true |
000073_mulan__00077_python2008__mulan-rework__中.ul | using 代码段 in 编辑器.代码段
using * in 编辑器.日志
using * in 编辑器.笔谈
using time
// TODO: 重构(提取 UI 无关部分并添加测试)
// TODO: 已知问题: 输入中文符号"("时,实际为退格,")"时为空格。thonny 也有同样问题。
if len(sys.argv) == 3 {
源码文件 = sys.argv[2]
} else {
源码文件 = "编辑器/中.ul"
}
源码 = 读文件内容(源码文件)
logging.info("打开源码文件:`源码文件`")
会话 = 笔谈(源码文件, 源码)
| .ul | mulan | MIT | A | 1ca38a7b75ed4be5c37c5899dd57a551f2faee9b2ac71380bfdaa98361c54c58 | 515 | 20 | 0.568421 | true |
000074_mulan__00078_python2008__mulan-rework__代码分析.ul |
using * in 木兰.分析器.词法分析器
using 代码段 in 编辑器.代码段
using * in 编辑器.常量
using * in 编辑器.日志
using 按某项生成映射 in 测试.实用.通用.结构
func 解析(源码) {
各词 = 分词器.lex(源码)
各代码段 = list(map(词 -> {
行号 = 词.getsourcepos().lineno
列号 = 词.getsourcepos().colno - 1
内容 = 词.getstr()
词长 = len(内容)
词性 = 词.name
if 词性 == 标识符 {
... | .ul | mulan | MIT | A | abe2be42a4b8f591d03c8a75e701e3b2cb31c788d211bf3d248891fc9025f0dc | 4,431 | 142 | 0.678125 | true |
000075_mulan__00079_python2008__mulan-rework__代码段.ul |
type 代码段 {
func $代码段(词性, 内容, 行, 起, 止) {
$词性 = 词性
$内容 = 内容
$行 = 行
$起, $止 = 起, 止
}
func $开始 {
return "`$行`.`$起`"
}
func $结束 {
return "`$行`.`$止`"
}
func $位置重合(另一代码段) {
return 另一代码段 and $行 == 另一代码段.行 and $起 == 另一代码段.起 and $止 == 另一代码段.止
}
operator == (另一代码段) {
return $位... | .ul | mulan | MIT | A | daa0a87ce826c349e1041c4fa9afa75867d495769ea01ee1cf3b5b2e530a917f | 678 | 29 | 0.582474 | true |
000076_mulan__00080_python2008__mulan-rework__常量.ul |
using * in 木兰.分析器.词法分析器
空格 = "空格"
注释 = "注释"
内置函数 = "函数"
内置类型 = "类型"
自身 = "self"
内置类型表 = set(["str", "list"])
内置函数表 = set(["len", "all", "filter", "map", "print"])
// TODO: 颜色常量化
高亮风格 = {
"紫红": [动词_引用, 动词_返回, 连词_于, 连词_对, 连词_每当, 连词_如果, 连词_否则如果, 连词_否则, 点点小于, 点点, 动词_终止, 动词_跳过],
"黄绿": [整数],
"橙": [双引号字符串, 单引号... | .ul | mulan | MIT | A | 54b0ce8e1d8507c1be785b79a31ebac98614302415b987c155fab23d4fd286a9 | 1,210 | 45 | 0.575198 | true |
000077_mulan__00081_python2008__mulan-rework__日志.ul | using logging
日志文件 = '编辑器/事件.log'
logging.basicConfig(
filename=日志文件,
format='%(asctime)s %(message)s',
level=logging.INFO)
| .ul | mulan | MIT | B | b1f3478cb76ff8b1109bdcdb299fe96f1055fc666381b7bc7b4806546464e946 | 158 | 8 | 0.141304 | true |
000078_mulan__00082_python2008__mulan-rework__笔谈.ul | using * in tkinter
using Font in tkinter.font
using scrolledtext in tkinter
using * in 编辑器.代码分析
using * in 编辑器.常量
using * in 编辑器.日志
using * in 编辑器.词.常量
默认要求 = "`动词.保存.value`"
/* TODO: 在 HTML 的代码编辑器效果达到 tk 版本后, 删除 tk 相关部分 */
type 笔谈 : Tk {
func $笔谈(源码文件, 源码) {
$源码文件 = 源码文件
$源码 = 源码
root = Tk()
ro... | .ul | mulan | MIT | A | 12f69b2520452045ecd1e162d367dc182b82c0c922dd8df4fbbf6f01f224242b | 3,271 | 113 | 0.302651 | true |
000079_mulan__00083_python2008__mulan-rework__统计行数.ul | using Path in pathlib
using json
func 有几行(文件名) {
f = open(文件名, 'r', encoding='utf-8')
内容 = f.read()
f.close()
// 末尾空行不算
return #内容.strip().split('\n')
}
// TODO: 略过 .gitignore 部分
各文件类型忽略目录 = {
'py': set(['.eggs', 'build', '临时']),
'ul': set(['临时'])
}
各源码文件行数 = {:}
各文件类型行数 = {:}
for 扩展名 in 各文件类型忽略目录 {
总... | .ul | mulan | MIT | A | 7a8e9ea5e13e1ca433a05aa41ccb6eba3cf080d4874955ee182f3fe42dd5ef8b | 1,052 | 34 | 0.446429 | true |
000080_mulan__00084_python2008__mulan-rework__行数差异.ul | using DeepDiff in deepdiff
using Path in pathlib
using json
func 读取(文件名) {
try 文件 = open(文件名, 'r', encoding="utf-8") { return json.load(文件) }
}
旧行数, 新行数 = 读取('临时/行数统计_0718.json'), 读取('临时/行数统计_0725.json')
func 取总行数(各文件行数) {
各类型行数 = {'py':0, 'ul':0}
for 文件名 in 各文件行数 {
各类型行数[文件名[-2:]] += 各文件行数[文件名]
}
retu... | .ul | mulan | MIT | A | 3ed985a33872b204c646f2362951104b01d57a1a03850c82b4970a9453e2c47c | 2,227 | 51 | 0.551546 | true |
000081_mulan__00085_python2008__mulan-rework__过往请求.ul | using SQLAlchemy in tornado_sqlalchemy
using DateTime, Column, String in sqlalchemy
db = SQLAlchemy(url="sqlite:///编辑器/请求历史.db")
type 过往请求 : db.Model {
{
__tablename__ = '请求历史'
时间 = Column(DateTime, primary_key=true)
请求 = Column(String(255))
}
func $__repr__ {
return str($时间) + $请求
}
}
| .ul | mulan | MIT | B | 6601a26dc53ed991df0c498a50f91d7308c9694f29853995ca39eb4a91aec6b5 | 361 | 17 | 0.118557 | true |
000082_mulan__00086_python2008__mulan-rework__运行.ul | using logging
using tornado.ioloop
using tornado.web
using Path in pathlib
using 预估请求 in 编辑器.访问处理.预估请求
using 聊天渠道 in 编辑器.访问处理.聊天渠道
using 首页 in 编辑器.访问处理.首页
using db in 编辑器.过往请求
type 应用 : tornado.web.Application {
func $应用 {
相应处置 = [tuple("/", 首页),
tuple("/chatsocket", 聊天渠道),
tuple("/requests", 预... | .ul | mulan | MIT | B | 2582b9fad0bb35625cf3bb31fa3b04d039099b7283a10b35cf2e05d9ceff3421 | 892 | 38 | 0.237745 | true |
000083_mulan__00087_python2008__mulan-rework__代码分析.ul | using * in 编辑器.代码分析
using 相等 in 测试.实用.通用.测试相关
using * in 编辑器.常量
空函数 = "func a {\n \n}"
后段注释 = "a = -1// b"
部分函数 = "func a {\n return 1"
后段空格 = "a = 1 "
空行 = ""
两层 = "func a {\nif 1 {\nreturn 1\n}\n}"
带多余空格 = "if 1{\nreturn 1\n \n}"
带tab = "if 1{\n return 1\n\t\n}"
带空行 = "if 1{\n return 1\n\n}"
空行在前 = "if 1{\n\n... | .ul | mulan | MIT | A | 027d56a7c79dd6064f534bf83d754e1437110e3af7c1819dae00f80d4fafa34a | 2,213 | 53 | 0.66716 | true |
000084_mulan__00088_python2008__mulan-rework__基本.ul | /* 不 */
func 累积(上限) {
数 = 888
文 = "666"
return 0
} | .ul | mulan | MIT | A | 3ce234723535ee5f2dc18f64def7aebbaf9c22d28be9502869e43b1e55d16782 | 70 | 6 | 0.411765 | true |
000085_mulan__00089_python2008__mulan-rework__注释误判.ul | if 1 {
}
else {
}
/*
else 会被识别为注释(绿色)
*/ | .ul | mulan | MIT | A | b4aad042d6187e56f239136d2343fc2d2b6a1441c8178bbe420d802b732ab96a | 60 | 9 | 0.473684 | true |
000086_mulan__00090_python2008__mulan-rework__聊天渠道.ul | using datetime
using logging
using uuid
using tornado.escape
using tornado.websocket
using SessionMixin in tornado_sqlalchemy
using 过往请求 in 编辑器.过往请求
using 读文件内容, 保存文件 in 编辑器.笔谈
using 运行木兰代码 in 编辑器.运行木兰
type 聊天渠道 : SessionMixin, tornado.websocket.WebSocketHandler {
func $on_message(内容) {
logging.info("收到消息: %r"... | .ul | mulan | MIT | A | c7181d44ebc73289de1bb01e91d3cfae33f8c43ddbcb20130d3f0c6ca0bf3364 | 1,798 | 58 | 0.330544 | true |
000087_mulan__00091_python2008__mulan-rework__预估请求.ul | using logging
using tornado.web
using SessionMixin in tornado_sqlalchemy
using desc, distinct in sqlalchemy
using 过往请求 in 编辑器.过往请求
type 预估请求: SessionMixin, tornado.web.RequestHandler {
func $get {
提示 = self.get_argument('term', nil)
所有请求 = []
// TODO: 优化?
历史请求 = self.session.query(过往请求)
if 提示 !... | .ul | mulan | MIT | B | 042a54366d5bb7e2fcf6f7c22e3f43b890eba33123657bd43f345d6a72cbbe77 | 934 | 29 | 0.2723 | true |
000088_mulan__00092_python2008__mulan-rework__首页.ul | using tornado.web
type 首页 : tornado.web.RequestHandler {
func $get {
$render("首页.html", 所有对话=[])
}
}
| .ul | mulan | MIT | B | 69b11d12fdfe141258b15cb25a964675c36691501957d119c10ce835e7b617a1 | 126 | 7 | 0.117647 | true |
000089_mulan__00093_python2008__mulan-rework__常量.ul | using Enum in enum
type 动词 : Enum {
{
格式化 = "格式化"
保存 = "保存"
}
} | .ul | mulan | MIT | A | ba61c0048bde3cfeb4e7b9504453ae0cb6a8e1f2f94b956f0ee5ffbdb4472fc2 | 100 | 8 | 0.342857 | true |
000090_mulan__00095_xy1282127821__mulan-rework__命令行.ul | using Cmd in cmd; using 随机范围数 in 随机数
type 猜数字 : Cmd {
{
intro, prompt = "木兰想了个 100 之内的数,猜是几?", "猜猜吧: "
想的 = 随机范围数(1000) / 10; 历史 = []; 至今最近 = 100
}
func $default(行) {
try { 数 = int(行) }
catch 例外 : ValueError { println("`行` 不是数,请再试"); return }
$历史.append(数); $比较(数)
}
func $比较(数) {
if... | .ul | mulan | MIT | A | 366223d2d1282491b91d94d5606e5977d511b4c2fbba95accbc3d30cf4b169b1 | 828 | 28 | 0.412409 | true |
000091_mulan__00096_xy1282127821__mulan-rework__草蟒_海龟.ul | using * in 海龟
颜色("黄色", "红色")
开始填充()
for 转角 in 0..4 {
前进(200); 右转(144)
}
结束填充()
主循环()
/* 需安装 Python 库“草蟒”: grasspy-modules */ | .ul | mulan | MIT | A | 7c5a0f4157cc45573bd35fbfc5fd7b87c32016a6b0351593876acc8a2eb63dd9 | 195 | 10 | 0.5 | true |
000092_mulan__00097_cndp__mulan-rework__变长参数.ul | func 回复(...) {
print(...)
}
回复(1, 2, 3) | .ul | mulan | MIT | A | caefd8ed25da7b1504389638e7328612c8b5eee1c2326fbba4d5f0e3cccd9936 | 51 | 4 | 0.307692 | true |
000093_mulan__00098_nianqingmallhq__mulan-rework__匿名函数.ul | print(list(filter(func (n) { return n>0 }, [1,-1])))
print(list(filter(n -> n>0, [1,-1])))
print(list(filter(n -> {
平方 = n*n
return 平方>5
}, [1,3])))
print(list(filter(
边长 -> { 面积 = 边长 * 边长; return 面积 > 5 },
[1,3]
)))
print(list(map(
func (边长) { 面积 = 边长 * 边长; return 面积 },
[1, 2]
)))
print(func (长, 宽) {
面积 ... | .ul | mulan | MIT | B | 883ee1ab2968d7335ad3ba1ab8f64b8d8260e74f48f9b8926bbde853657f4d19 | 494 | 24 | 0.212766 | true |
000094_mulan__00099_nianqingmallhq__mulan-rework__乘.ul | print(2*3)
长 = 2
宽 = 3
print(3长 + 4 宽)
print(6/2(1+2)) | .ul | mulan | MIT | B | 968d68b8980af02fdde5be43e275e568d502e2acc309a9f918fda8a28877ab2e | 62 | 5 | 0.210526 | true |
000095_mulan__00100_labsite__mulan-rework__扩展拆字游戏.ul | using json
部分1 = "又寸土工斤木白旦各莫十分丁户少合青鸟包羊月古"
部分2 = "亻讠木又火口目⺼扌日氵𧾷宀艹广门辶"
// 待加:广门辶
// 待定: 纟钅
常用字数据 = open('测试/实用/字/常用字拆字.json', 'r', encoding="utf-8")
拆字 = json.load(常用字数据)
常用字数据.close()
func 搜索偏旁(偏旁) {
字数 = 0
所有字 = []
for 字 in 拆字 {
字型, 部分 = 拆字[字]['字型'], 拆字[字]['部分']
if 部分[0] == 偏旁 or 部分[1] == 偏旁 {
字... | .ul | mulan | MIT | A | 64df40cf0a427754be9dc834ad86c61978729b28060f630b93c91a633b9fe368 | 1,698 | 63 | 0.602062 | true |
000096_mulan__00101_labsite__mulan-rework__聊天演示.ul | /*
#!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | .ul | mulan | MIT | B | d862a5d359a4c78b2860aa26057292f873b59288c27ad887350140323e6f1ee4 | 3,267 | 124 | 0.153268 | true |
000097_mulan__00102_hrw123__mulan-rework__运算.ul | 长 = 6
宽 = 2
println(长 == 3宽)
println(2^3宽)
// println(-1 宽..4 宽 by 2 宽)
// println(-1..6)
println(-1 ? 1 : 2..true ? 6 : 5)
println(-1..true)
println(1==-1..4)
println(-1..4 + 5)
| .ul | mulan | MIT | B | 9b982013e6478f596bc6c7d118e82cc3338c16f5e6f06ed83b4cb0ef730dff8e | 195 | 10 | 0.108108 | true |
000098_mulan__00103_hydrati__mulan-rework__命令行.ul | using Cmd in cmd; using exit in sys; using 随机范围数 in 随机数
type 猜数字 : Cmd {
{
intro, prompt = "木兰想了个 100 之内的数,猜是几?", "猜猜吧: "
想的 = 随机范围数(1000) / 10; 历史 = []; 至今最近 = 100
}
func $default(行) {
try { 数 = int(行) }
catch 例外 : ValueError { println("`行` 不是数,请再试"); return }
$历史.append(数); $比较(数)
}
f... | .ul | mulan | MIT | A | 4e0a75ddc1fe1b84cc2317aa0c23ae74f19cd81bd56e0be1b6331c733d68a474 | 856 | 28 | 0.392361 | true |
000099_mulan__00104_Jameskinglzz__mulan-rework__儿歌.ul | type 儿歌 {
func $儿歌(题目, 内容) {
self.题目 = 题目
self.内容 = 内容
}
}
func 春天在哪里小节(哪儿, 有啥) {
return ["春天在哪里呀 春天在哪里", "春天在那" + 哪儿 + "里", 有啥,
"还有那会唱歌的小黄鹂"] +
["嘀哩哩哩哩嘀哩哩嘀哩哩哩哩哩"] * 2 +
["春天在" + 哪儿 + "里", "还有那会唱歌的小黄鹂"]
}
春天在哪里 = 儿歌("春天在哪里",
春天在哪里小节("青翠的山林", "这里有红花呀 这里有绿草") +
春天在哪里小... | .ul | mulan | MIT | A | 154558155a30837317c22800a3316724d24d3b1060fe052c590754292fd10ad4 | 8,737 | 318 | 0.968412 | true |
Natively-authored multilingual code for the Language Decoded project (part of Cohere's Tiny Aya Expedition). This dataset contains code written by developers in non-English programming languages and code with significant CJK content — not mechanically transpiled from English.
This data serves as a component of Condition 3 ("Mixed Native Sources") and Condition 4 ("Strictly Native Code") in the Language Decoded experiment, which tests whether native-language code improves multilingual reasoning beyond keyword swapping alone.
| Config | Language | Files | Description |
|---|---|---|---|
zh |
Chinese | 3,486 | Natively Chinese-authored code from 5 sources |
| Column | Type | Description |
|---|---|---|
filename |
string | Unique file identifier |
content |
string | Full file content |
extension |
string | File extension (e.g., .py, .java, .wy, .qi) |
source |
string | Origin dataset or project |
license |
string | SPDX license identifier or UNKNOWN |
quality_tier |
string | Quality tier: A (highest), B, C, D |
sha256 |
string | SHA-256 hash of file content for deduplication |
byte_size |
int64 | File size in bytes |
total_lines |
int64 | Number of lines in the file |
cjk_ratio |
float | Ratio of CJK characters to total non-whitespace chars |
has_cjk |
bool | Whether the file contains any CJK characters |
zh) Source Breakdown
| Source | Files | Extensions | Description |
|---|---|---|---|
thestack |
1,948 | .py, .js, .java, … | Code from The Stack with CJK in comments, strings, identifiers |
program_in_chinese |
703 | .java, .js, .ts, … | Program in Chinese — code with Chinese identifiers |
qi |
239 | .qi | Qi — Chinese-syntax programming language |
mulan |
166 | .ul | Mulan — Chinese programming language |
wenyan |
81 | .wy | Wenyan — Classical Chinese programming language (20K+ GitHub stars) |
| Tier | Count | Description |
|---|---|---|
| A | 778 | High quality, rich CJK |
| B | 1,158 | Good quality |
| C | 789 | Moderate quality |
| D | 412 | Lower quality, sparse CJK |
| Extension | Count | Extension | Count |
|---|---|---|---|
| .py | 2,003 | .ul | 166 |
| .java | 288 | .wy | 81 |
| .qi | 239 | .ts | 59 |
| .js | 205 | .c | 36 |
| Others | 59 |
from datasets import load_dataset
# Load Chinese native code
ds = load_dataset("legesher/language-decoded-community", "zh")
train = ds["train"] # 3,137 files
val = ds["validation"] # 349 files
# Filter by source
wenyan = train.filter(lambda x: x["source"] == "wenyan")
# Filter by quality
high_quality = train.filter(lambda x: x["quality_tier"] in ("A", "B"))
language-decoded-data.thestack) have UNKNOWN licenses. These were included because they appeared in The Stack's permissive-license subset, but individual file licenses could not always be verified.@misc{language-decoded-2026,
title={Language Decoded: Investigating Language-Dependent vs. Structure-Dependent Reasoning Benefits of Code},
author={Madison Edgar and Saad Ahmed Bazaz and Tom Sherborne and Rashik Shahjahan and Khojasteh Mirza and Sarah Jawaid and Rafay Mustafa and Sohaib Ahmed Bazaz},
year={2026},
publisher={Hugging Face},
url={https://huggingface.co/datasets/legesher/language-decoded-community}
}
Apache 2.0