You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(defclass rat
:super propertied-object
:slots (x))
(defmethod rat
(:init
(&optional n d)
(send self :make-rat n d)
self)
(:make-rat (n d) (setq x (cons n d)))
(:numer () (car x))
(:denom () (cdr x))
(:add-rat (x y)
(:make-rat (+ (* (:numer x) (:denom y))
(* (:numer y) (:denom x)))
(* (:denom x) (:denom y))))
(setq z (cons (+ (* (car x) (cdr y)) (* (car y) (cdr x)) ) (* (cdr x) (cdr y)) )))
(:print-info
()
(send-all members :print-info)))
のように定義したのですが、
8.irteusgl$ setq a (instance rat :init)
#<rat #X55c19d49e418>
9.irteusgl$ send a :make-rat 1 2
(1 . 2)
10.irteusgl$ setq b (instance rat :init)
#<rat #X55c19d506c40>
11.irteusgl$ send b :make-rat 1 3
(1 . 3)
12.irteusgl$ setq c (instance rat :init)
#<rat #X55c19d509010>
13.irteusgl$ send c :add-rat a b
Call Stack (max depth: 20):
0: at (send c :add-rat a b)
1: at #<compiled-code #X55c19d1d43e8>
irteusgl 0 error: undefined function :make-rat in (send c :add-rat a b)
としてadd-ratを呼び出そうとすると、関数が定義されていないというエラーが出てしまいました。
また、変数cにadd-rat関数の返り値を代入しようと思って、
「setq c :add-rat a b」
とすると、cにadd-rat関数そのものが代入されてしまいうまく行きませんでした。
:add-rat関数はどのようにして呼び出せば良いのでしょうか。
The text was updated successfully, but these errors were encountered:
課題2について質問です。
ratクラスを
のように定義したのですが、
としてadd-ratを呼び出そうとすると、関数が定義されていないというエラーが出てしまいました。
また、変数cにadd-rat関数の返り値を代入しようと思って、
「setq c :add-rat a b」
とすると、cにadd-rat関数そのものが代入されてしまいうまく行きませんでした。
:add-rat関数はどのようにして呼び出せば良いのでしょうか。
The text was updated successfully, but these errors were encountered: