[過去ログ] 関数型プログラミング言語Haskell Part33 (1002レス)
上下前次1-新
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
414: デフォルトの名無しさん [] 2020/08/22(土)13:18 ID:g0O87mtN(1/2)
空気読まずに有限集合でやってみる。
``` code
#{-# LANGUAGE ExistentialPython #-}
import math;
import random;
import string;
def none ():
dot = lambda bc, ab: {a : bc [b] for a, b in ab.items ()};
make_map = lambda a, b: dict (zip (a, random.choices (b, k = len (a))));
A = tuple (range (5));
B = random.sample (string.ascii_lowercase, 10);
C = random.sample (string.ascii_uppercase, 8);
D = (math.nan, math.inf, None, (), 'hello', 'world');
ab = make_map (A, B);
bc = make_map (B, C);
cd = make_map (C, D);
assert dot (cd, dot (bc, ab)) == dot (dot (cd, bc), ab);
return ((A, B, C, D), (ab, bc, cd));
out = none ();
```
自分の知る限り、素朴な写像の描像が描けないガジェットに対して「写像」という
言葉は使わないので、写像が結合的かどうかという議論に意味があると思えない。
415: デフォルトの名無しさん [] 2020/08/22(土)13:19 ID:g0O87mtN(2/2)
``` code
#{-# LANGUAGE FunctionalJupyter #-}
import IPython.display as display;
def none (node, edge):
f = lambda col, a: {key : (row, col) for row, key in enumerate (a)};
nodes = {};
for val in [f (j, a) for j, a in enumerate (node)]: nodes.update (val);
edges = [];
for xy in edge: edges += [(nodes [x], nodes [y]) for x, y in xy.items ()];
node_out = r"""<text class='clazz' x='{x}' y='{y}'>{z}</text>""";
edge_out = r"""<line class='clazz' x1='{x_0}' y1='{y_0}' x2='{x_1}' y2='{y_1}'/>""";
out = '';
w, h, dw = 100, 20, 20;
for key, val in nodes.items (): out += node_out.format (x = w * val [1], y = h * val [0], z = key);
for a, b in edges: out += edge_out.format (x_0 = w * a [1] + dw, y_0 = h * a [0], x_1 = w * b [1] - dw, y_1 = h * b [0]);
style = r"""<style> text.clazz { dominant-baseline: middle; text-anchor: middle; } line.clazz { stroke: black; fill: none; } </style> """.strip ();
svg = f"""<svg width='400' height='300' viewBox='{-20} {-20} {len (node) * w + 20} {max (map (len, node)) * h + 20}'>{out}</svg>""";
display.display (display.HTML (style + svg));
return None;
none (*out);
```
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.040s