Skip to content

Commit

Permalink
use unicode for subscript number
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jul 30, 2023
1 parent 2a58c56 commit 4cb56ea
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 101 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use unicode for subscript number

`connect` v.s. `reconnect`

- `reconnect` is used in `PortReconnect`
Expand Down
16 changes: 8 additions & 8 deletions docs/tests/DiffList.inet.one_two_soles.finial.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(sole#1)-return head-(cons#2)
(sole#5)-return head-(cons#6)
(sole#7)-return head-(cons#8)
(cons#6)-return tail-(cons#8)
(cons#6)-tail left-(diff#13)
(cons#2)-return return-(cons#8)
(cons#2)-tail right-(diff#13)
(diff#13)-return
(sole)-return head-(cons)
(sole)-return head-(cons)
(sole)-return head-(cons)
(cons)-return tail-(cons)
(cons)-tail left-(diff₁₃)
(cons)-return return-(cons)
(cons)-tail right-(diff₁₃)
(diff₁₃)-return
22 changes: 11 additions & 11 deletions docs/tests/DiffList.inet.one_two_soles.initial.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(diff#9)-return!left-(diff_append#10)
(sole#1)-return head-(cons#2)
(cons#2)-return left-(diff#3)
(sole#5)-return head-(cons#6)
(sole#7)-return head-(cons#8)
(cons#6)-return tail-(cons#8)
(cons#8)-return left-(diff#9)
(diff#3)-return right-(diff_append#10)
(diff#3)-right tail-(cons#2)
(diff#9)-right tail-(cons#6)
(diff_append#10)-return
(diff)-return!left-(diff_append₁₀)
(sole)-return head-(cons)
(cons)-return left-(diff)
(sole)-return head-(cons)
(sole)-return head-(cons)
(cons)-return tail-(cons)
(cons)-return left-(diff)
(diff)-return right-(diff_append₁₀)
(diff)-right tail-(cons)
(diff)-right tail-(cons)
(diff_append₁₀)-return
20 changes: 10 additions & 10 deletions docs/tests/DiffList.inet.two_two_soles.finial.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(sole#15)-return head-(cons#16)
(sole#17)-return head-(cons#18)
(cons#16)-return tail-(cons#18)
(sole#21)-return head-(cons#22)
(sole#23)-return head-(cons#24)
(cons#22)-return tail-(cons#24)
(cons#22)-tail left-(diff#29)
(cons#18)-return return-(cons#24)
(cons#16)-tail right-(diff#29)
(diff#29)-return
(sole₁₅)-return head-(cons₁₆)
(sole₁₇)-return head-(cons₁₈)
(cons₁₆)-return tail-(cons₁₈)
(sole₂₁)-return head-(cons₂₂)
(sole₂₃)-return head-(cons₂₄)
(cons₂₂)-return tail-(cons₂₄)
(cons₂₂)-tail left-(diff₂₉)
(cons₁₈)-return return-(cons₂₄)
(cons₁₆)-tail right-(diff₂₉)
(diff₂₉)-return
26 changes: 13 additions & 13 deletions docs/tests/DiffList.inet.two_two_soles.initial.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(diff#25)-return!left-(diff_append#26)
(sole#15)-return head-(cons#16)
(sole#17)-return head-(cons#18)
(cons#16)-return tail-(cons#18)
(cons#18)-return left-(diff#19)
(sole#21)-return head-(cons#22)
(sole#23)-return head-(cons#24)
(cons#22)-return tail-(cons#24)
(cons#24)-return left-(diff#25)
(diff#19)-return right-(diff_append#26)
(diff#19)-right tail-(cons#16)
(diff#25)-right tail-(cons#22)
(diff_append#26)-return
(diff₂₅)-return!left-(diff_append₂₆)
(sole₁₅)-return head-(cons₁₆)
(sole₁₇)-return head-(cons₁₈)
(cons₁₆)-return tail-(cons₁₈)
(cons₁₈)-return left-(diff₁₉)
(sole₂₁)-return head-(cons₂₂)
(sole₂₃)-return head-(cons₂₄)
(cons₂₂)-return tail-(cons₂₄)
(cons₂₄)-return left-(diff₂₅)
(diff₁₉)-return right-(diff_append₂₆)
(diff₁₉)-right tail-(cons₁₆)
(diff₂₅)-right tail-(cons₂₂)
(diff_append₂₆)-return
26 changes: 13 additions & 13 deletions docs/tests/List.inet.six_soles.finial.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(sole#12)-return head-(cons#17)
(sole#5)-return head-(cons#19)
(cons#19)-return tail-(cons#17)
(sole#10)-return head-(cons#21)
(cons#21)-return tail-(cons#19)
(sole#3)-return head-(cons#23)
(cons#23)-return tail-(cons#21)
(sole#8)-return head-(cons#25)
(cons#25)-return tail-(cons#23)
(sole#1)-return head-(cons#27)
(cons#27)-return tail-(cons#25)
(null#0)-return tail-(cons#27)
(cons#17)-return
(sole₁₂)-return head-(cons₁₇)
(sole)-return head-(cons₁₉)
(cons₁₉)-return tail-(cons₁₇)
(sole₁₀)-return head-(cons₂₁)
(cons₂₁)-return tail-(cons₁₉)
(sole)-return head-(cons₂₃)
(cons₂₃)-return tail-(cons₂₁)
(sole)-return head-(cons₂₅)
(cons₂₅)-return tail-(cons₂₃)
(sole)-return head-(cons₂₇)
(cons₂₇)-return tail-(cons₂₅)
(null)-return tail-(cons₂₇)
(cons₁₇)-return
30 changes: 15 additions & 15 deletions docs/tests/List.inet.six_soles.initial.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(cons#13)-return!left-(append#14)
(sole#1)-return head-(cons#2)
(null#0)-return tail-(cons#2)
(sole#3)-return head-(cons#4)
(cons#2)-return tail-(cons#4)
(sole#5)-return head-(cons#6)
(cons#4)-return tail-(cons#6)
(sole#8)-return head-(cons#9)
(null#7)-return tail-(cons#9)
(sole#10)-return head-(cons#11)
(cons#9)-return tail-(cons#11)
(sole#12)-return head-(cons#13)
(cons#11)-return tail-(cons#13)
(cons#6)-return right-(append#14)
(append#14)-return
(cons₁₃)-return!left-(append₁₄)
(sole)-return head-(cons)
(null)-return tail-(cons)
(sole)-return head-(cons)
(cons)-return tail-(cons)
(sole)-return head-(cons)
(cons)-return tail-(cons)
(sole)-return head-(cons)
(null)-return tail-(cons)
(sole₁₀)-return head-(cons₁₁)
(cons)-return tail-(cons₁₁)
(sole₁₂)-return head-(cons₁₃)
(cons₁₁)-return tail-(cons₁₃)
(cons)-return right-(append₁₄)
(append₁₄)-return
10 changes: 5 additions & 5 deletions docs/tests/Nat.inet.four.finial.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(add1#35)-return prev-(add1#29)
(add1#37)-return prev-(add1#35)
(add1#41)-return prev-(add1#37)
(zero#14)-return prev-(add1#41)
(add1#29)-return
(add1₃₅)-return prev-(add1₂₉)
(add1₃₇)-return prev-(add1₃₅)
(add1₄₁)-return prev-(add1₃₇)
(zero₁₄)-return prev-(add1₄₁)
(add1₂₉)-return
22 changes: 11 additions & 11 deletions docs/tests/Nat.inet.four.initial.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(add1#17)-return!x-(add#18)
(add1#22)-return!x-(add#23)
(zero#14)-return prev-(add1#15)
(zero#16)-return prev-(add1#17)
(add1#15)-return y-(add#18)
(zero#19)-return prev-(add1#20)
(zero#21)-return prev-(add1#22)
(add1#20)-return y-(add#23)
(add#23)-return x-(add#24)
(add#18)-return y-(add#24)
(add#24)-return
(add1₁₇)-return!x-(add₁₈)
(add1₂₂)-return!x-(add₂₃)
(zero₁₄)-return prev-(add1₁₅)
(zero₁₆)-return prev-(add1₁₇)
(add1₁₅)-return y-(add₁₈)
(zero₁₉)-return prev-(add1₂₀)
(zero₂₁)-return prev-(add1₂₂)
(add1₂₀)-return y-(add₂₃)
(add₂₃)-return x-(add₂₄)
(add₁₈)-return y-(add₂₄)
(add₂₄)-return
6 changes: 3 additions & 3 deletions docs/tests/Nat.inet.two.finial.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(add1#13)-return prev-(add1#11)
(zero#4)-return prev-(add1#13)
(add1#11)-return
(add1₁₃)-return prev-(add1₁₁)
(zero)-return prev-(add1₁₃)
(add1₁₁)-return
10 changes: 5 additions & 5 deletions docs/tests/Nat.inet.two.initial.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(add1#7)-return!x-(add#8)
(zero#4)-return prev-(add1#5)
(zero#6)-return prev-(add1#7)
(add1#5)-return y-(add#8)
(add#8)-return
(add1)-return!x-(add)
(zero)-return prev-(add1)
(zero)-return prev-(add1)
(add1)-return y-(add)
(add)-return
2 changes: 1 addition & 1 deletion docs/tests/Nat.inet.zero_zero_add.finial.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(zero#0)-return
(zero)-return
6 changes: 3 additions & 3 deletions docs/tests/Nat.inet.zero_zero_add.initial.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(zero#1)-return!x-(add#2)
(zero#0)-return y-(add#2)
(add#2)-return
(zero)-return!x-(add)
(zero)-return y-(add)
(add)-return
19 changes: 18 additions & 1 deletion src/renderers/formatNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import { Node } from "../lang/graph"

export function formatNode(node: Node): string {
return `${node.name}#${node.id}`
const subscript = [...node.id.toString()]
.map((c) => numberSubscripts[c] || c)
.join("")

return `${node.name}${subscript}`
}

const numberSubscripts: Record<string, string> = {
"0": "₀",
"1": "₁",
"2": "₂",
"3": "₃",
"4": "₄",
"5": "₅",
"6": "₆",
"7": "₇",
"8": "₈",
"9": "₉",
}

0 comments on commit 4cb56ea

Please sign in to comment.