喜报,我还是懒得搞英文博客了!感觉完全没有动机喵。
CF 737 A. (*800)
C++ 解答
1 |
|
绷语言解答
1 | let t = input |
语言设计解读
- 简洁:出于语义性考虑,
sort
需要接受一个int -> int -> bool
,而>
可以被直接看成int -> int -> bool
,因此sort
可以直接接受>
作为参数。在 C++ 中则需要接受整个匿名函数,且匿名函数需要手动标注类型。 - 自然:为贴近人直觉上考虑问题的思路,
for n
既可以前置也可以后置,表示重复n
次。在 C++ 中则需要手写 while 或 for 循环来表达相同的语义。 - 自由:可以直接使用
input
来读入一个任意类型的东西,类型可以通过类型推导得出。在 C++ 中也可以自动推导类型,但需要手写std::cin
。 - 智能:直接支持创建变量长度的数组。在 C++ 中需要预先设置一个大常量。
- 专一:用
mut
(来自 Rust)和rec
(来自 OCaml)封装一切就地修改,在块内享受 C 的便捷,在块外享受函数式的严谨。在 C++ 中难以保证一个值未来不会被错误地修改,从而无法进行较为激进的编译器优化,程序逻辑也容易产生不可预料的问题。 - 丝滑:基于无括号元组的丝滑编辑体验。在 C++ 中需要使用
pair
。 - 严谨:利用
nope
关键字在显然不合理时跳出循环,若忘记添加nope
会无法编译通过。在 C++ 中则需要自己手动模拟程序运行并判断边界情况,更容易产生错误。
Reimagined
自递归
1 | main : Void |
辅助递归
1 | main : Void |