duangsuse::Echo
583 subscribers
4.12K photos
118 videos
579 files
6.13K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
#Python #code 突然想到
from itertools import accumulate
def generate(op, init, stop):
acc = init
while acc != stop: yield acc; acc = op(acc)
list(accumulate("是这样呢", lambda s,x: s+x))
_ == ['是', '是这', '是这样', '是这样呢']
list(generate(lambda s: s[1:], "不可能啊", ""))
_ == ['不可能啊', '可能啊', '能啊', '啊']

话说 permutations 是指 combinations 的 (a,b) 形式啊... 这么高级
还有 product ,真有意思, equivalent to nested loop: product(xs, ys) = ((x,y) for x in xs for y in ys)
tee 用于复制流,也有一定组合潜力

还有一个版本 #trap
def generate(op, init, stop):
acc = init; yield acc
while acc != stop: acc = op(acc); yield acc

会 yield 个 stop ,原来是在 while != 检查之前 yield acc 了... 变量更新表还是要跟踪下 😴