[過去ログ]
関数型プログラミング言語Haskell Part33 (1002レス)
関数型プログラミング言語Haskell Part33 http://mevius.5ch.net/test/read.cgi/tech/1581326256/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
414: デフォルトの名無しさん [] 2020/08/22(土) 13:18:34.82 ID:g0O87mtN 空気読まずに有限集合でやってみる。 ``` 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 (); ``` 自分の知る限り、素朴な写像の描像が描けないガジェットに対して「写像」という 言葉は使わないので、写像が結合的かどうかという議論に意味があると思えない。 http://mevius.5ch.net/test/read.cgi/tech/1581326256/414
415: デフォルトの名無しさん [] 2020/08/22(土) 13:19:16.92 ID:g0O87mtN ``` 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); ``` http://mevius.5ch.net/test/read.cgi/tech/1581326256/415
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.035s