Post Reply 
Reproducible crash with badly defined function
11-07-2022, 09:14 PM
Post: #2
RE: Reproducible crash with badly defined function
CAS> f := x -> Ans^2 // Ans = f
CAS> f(2)                   // = f^2 = (x->f^2)^2 = (x->(x->f^2))^2 ..., causing crash

If the goal is to write a thunk to square Ans, we can use indirection, CAS.Ans instead of Ans

CAS> f := NULL -> CAS.Ans^2
CAS> f() // no argument needed, no crash
(program({},{},(double_deux_points(CAS,Ans))^2))^2
(program({},{},(double_deux_points(CAS,Ans))^2))^4
(program({},{},(double_deux_points(CAS,Ans))^2))^8

CAS> 10
CAS> f()
100
10000
100000000
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Reproducible crash with badly defined function - Albert Chan - 11-07-2022 09:14 PM



User(s) browsing this thread: 1 Guest(s)