0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VALGOL II マシーンを作る

Posted at
1 / 8

META II の論文から VALGOL II コンパイラと行列式を求めるサンプルプログラムを打ち込んでコンパイルまで行った。


でも…

VALGOL II 仮想マシンの仕様が想定外だったり、読んでもよくわからなかったりで完成しなかった。

「スタックの上から二番目のアドレス」っていうのはそこに入っているアドレス値のことなのか、スタックのその場所のアドレスのことなのか…。


余談

VALGOL I は放物線を描くプログラムなのだけど、

148: リスナーさん :2018/12/21(金) 21:03:18
    rubyで円を描くのは
    簡単ですか?

##ってことで僕が書いたのがこれ。

y = -1.0

while y <= 1.0
  t = Math.asin(y)
  x = Math.cos(t)
  print_area = ' '*60
  [20 + (x*20).round, 20 - (x*20).round].each do |col|
    print_area[col] = '*'
  end↲
  puts print_area
  y += 0.1
end

出力

                    *
           *                 *
        *                       *
      *                           *
    *                               *
   *                                 *
  *                                   *
 *                                     *
*                                       *
*                                       *
*                                       *
*                                       *
*                                       *
 *                                     *
  *                                   *
   *                                 *
    *                               *
      *                           *
        *                       *
           *                 *
                    *

上と下にスキマが空いちゃってるね。


リスナーさんが書いたのがこれ↓

def print_circle(r)
  (-r..r).to_a.each do |x|
    (-r..r).to_a.each do |y|
      if x ** 2 + y ** 2 <= r ** 2
        print '()'
      else
        print ' '
      end
    end
    print "\n"
  end
end

print_circle(10)

出力↓

          ()          
      ()()()()()()()()()      
    ()()()()()()()()()()()()()    
   ()()()()()()()()()()()()()()()   
  ()()()()()()()()()()()()()()()()()  
  ()()()()()()()()()()()()()()()()()  
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
()()()()()()()()()()()()()()()()()()()()()
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
 ()()()()()()()()()()()()()()()()()()() 
  ()()()()()()()()()()()()()()()()()  
  ()()()()()()()()()()()()()()()()()  
   ()()()()()()()()()()()()()()()   
    ()()()()()()()()()()()()()    
      ()()()()()()()()()      
          ()
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?