VOOZH about

URL: https://qiita.com/ohisama@github/items/e35eb633fbe27b7ba61e

⇱ 高位合成言語アセンブラを作る。 その6 #Python - Qiita


👁 Image
0

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@ohisama@github

高位合成言語アセンブラを作る。 その6

0
Posted at

概要

高位合成言語アセンブラを作る。
pythonで、真理値表から論理式、求めてみた。

サンプルコード

import sympy as sym

# xor
print (sym.POSform(['a', 'b'], [[1, 0], [0, 1]]))
# or
print (sym.POSform(['a', 'b'], [[1, 1], [0, 1], [1, 0]]))
# and
print (sym.POSform(['a', 'b'], [[1, 1]]))
# nand
print (sym.POSform(['a', 'b'], [[0, 0], [0, 1], [1, 0]]))
# nor
print (sym.POSform(['a', 'b'], [[0, 0]]))

print (sym.POSform(['a', 'b', 'c'], [[1, 1, 1]]))

実行結果

(a | b) & (~a | ~b)
a | b
a & b
~a | ~b
~a & ~b
a & b & c

以上。

0

Go to list of users who liked

0
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0

Go to list of users who liked

0