## [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments

 [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments From: SourceForge.net - 2009-12-30 10:40:34 ```Bugs item #2922933, was opened at 2009-12-29 17:35 Message generated for change (Comment added) made by rui_maciel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rui Maciel (rui_maciel) Assigned to: Nobody/Anonymous (nobody) Summary: Defining function from expression doesn't relate arguments Initial Comment: Let's say we have the following expression: a: (x - 1)*x*(y - 1)*y*(z - 1)*z/8; and let's say we declare the following function: f(x,y,z) := a; If we pass arguments to that function, the function fails to replace the expression's variables with the value of the arguments passed to the function. For example: (%i387) f(0,0,0); (x - 1) x (y - 1) y (z - 1) z (%o387) ----------------------------- 8 Yet, if the expression's variables are substituted in the function declaration then everything works as expected: (%i388) f(b,c,d) := subst([x=b,y=c,z=d],a); (%o388) f(b, c, d) := subst([x = b, y = c, z = d], a) (%i389) f(0,0,0); (%o389) 0 That extra call to subst() should not be needed in order to successfully declare a function from an expression. ---------------------------------------------------------------------- >Comment By: Rui Maciel (rui_maciel) Date: 2009-12-30 10:40 Message: That's weird. It appears it works with the define() function but if the := operator is used directly then the function definition fails. For example: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x - 1)*x*(y - 1)*y*(z - 1))*z/8; (%i2) f(x,y,z) := %; (%o2) f(x, y, z) := % (%i3) f(0,0,0); (%o3) f(x, y, z) := % (%i4) define(f(x,y,z), %o1); (%o4) f(x, y, z) := ((x - 1)*x*(y - 1)*y*(z - 1)*z)/8 (%i5) f(0,0,0); (%o5) 0 Is this a bug or is this behaviour expected? ---------------------------------------------------------------------- Comment By: Aleksas Domarkas (alex108) Date: 2009-12-30 05:56 Message: You can successfully declare a function from an expression: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i2) define(f(x,y,z),%); (%o2) f(x,y,z):=((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i3) f(0,0,0); (%o3) 0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 ```

 [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments From: SourceForge.net - 2009-12-29 17:35:38 ```Bugs item #2922933, was opened at 2009-12-29 17:35 Message generated for change (Tracker Item Submitted) made by rui_maciel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rui Maciel (rui_maciel) Assigned to: Nobody/Anonymous (nobody) Summary: Defining function from expression doesn't relate arguments Initial Comment: Let's say we have the following expression: a: (x - 1)*x*(y - 1)*y*(z - 1)*z/8; and let's say we declare the following function: f(x,y,z) := a; If we pass arguments to that function, the function fails to replace the expression's variables with the value of the arguments passed to the function. For example: (%i387) f(0,0,0); (x - 1) x (y - 1) y (z - 1) z (%o387) ----------------------------- 8 Yet, if the expression's variables are substituted in the function declaration then everything works as expected: (%i388) f(b,c,d) := subst([x=b,y=c,z=d],a); (%o388) f(b, c, d) := subst([x = b, y = c, z = d], a) (%i389) f(0,0,0); (%o389) 0 That extra call to subst() should not be needed in order to successfully declare a function from an expression. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments From: SourceForge.net - 2009-12-30 05:56:33 ```Bugs item #2922933, was opened at 2009-12-29 19:35 Message generated for change (Comment added) made by alex108 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rui Maciel (rui_maciel) Assigned to: Nobody/Anonymous (nobody) Summary: Defining function from expression doesn't relate arguments Initial Comment: Let's say we have the following expression: a: (x - 1)*x*(y - 1)*y*(z - 1)*z/8; and let's say we declare the following function: f(x,y,z) := a; If we pass arguments to that function, the function fails to replace the expression's variables with the value of the arguments passed to the function. For example: (%i387) f(0,0,0); (x - 1) x (y - 1) y (z - 1) z (%o387) ----------------------------- 8 Yet, if the expression's variables are substituted in the function declaration then everything works as expected: (%i388) f(b,c,d) := subst([x=b,y=c,z=d],a); (%o388) f(b, c, d) := subst([x = b, y = c, z = d], a) (%i389) f(0,0,0); (%o389) 0 That extra call to subst() should not be needed in order to successfully declare a function from an expression. ---------------------------------------------------------------------- Comment By: Aleksas Domarkas (alex108) Date: 2009-12-30 07:56 Message: You can successfully declare a function from an expression: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i2) define(f(x,y,z),%); (%o2) f(x,y,z):=((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i3) f(0,0,0); (%o3) 0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments From: SourceForge.net - 2009-12-30 10:40:34 ```Bugs item #2922933, was opened at 2009-12-29 17:35 Message generated for change (Comment added) made by rui_maciel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Rui Maciel (rui_maciel) Assigned to: Nobody/Anonymous (nobody) Summary: Defining function from expression doesn't relate arguments Initial Comment: Let's say we have the following expression: a: (x - 1)*x*(y - 1)*y*(z - 1)*z/8; and let's say we declare the following function: f(x,y,z) := a; If we pass arguments to that function, the function fails to replace the expression's variables with the value of the arguments passed to the function. For example: (%i387) f(0,0,0); (x - 1) x (y - 1) y (z - 1) z (%o387) ----------------------------- 8 Yet, if the expression's variables are substituted in the function declaration then everything works as expected: (%i388) f(b,c,d) := subst([x=b,y=c,z=d],a); (%o388) f(b, c, d) := subst([x = b, y = c, z = d], a) (%i389) f(0,0,0); (%o389) 0 That extra call to subst() should not be needed in order to successfully declare a function from an expression. ---------------------------------------------------------------------- >Comment By: Rui Maciel (rui_maciel) Date: 2009-12-30 10:40 Message: That's weird. It appears it works with the define() function but if the := operator is used directly then the function definition fails. For example: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x - 1)*x*(y - 1)*y*(z - 1))*z/8; (%i2) f(x,y,z) := %; (%o2) f(x, y, z) := % (%i3) f(0,0,0); (%o3) f(x, y, z) := % (%i4) define(f(x,y,z), %o1); (%o4) f(x, y, z) := ((x - 1)*x*(y - 1)*y*(z - 1)*z)/8 (%i5) f(0,0,0); (%o5) 0 Is this a bug or is this behaviour expected? ---------------------------------------------------------------------- Comment By: Aleksas Domarkas (alex108) Date: 2009-12-30 05:56 Message: You can successfully declare a function from an expression: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i2) define(f(x,y,z),%); (%o2) f(x,y,z):=((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i3) f(0,0,0); (%o3) 0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-2922933 ] Defining function from expression doesn't relate arguments From: SourceForge.net - 2010-01-10 23:54:59 ```Bugs item #2922933, was opened at 2009-12-29 18:35 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Rui Maciel (rui_maciel) Assigned to: Nobody/Anonymous (nobody) Summary: Defining function from expression doesn't relate arguments Initial Comment: Let's say we have the following expression: a: (x - 1)*x*(y - 1)*y*(z - 1)*z/8; and let's say we declare the following function: f(x,y,z) := a; If we pass arguments to that function, the function fails to replace the expression's variables with the value of the arguments passed to the function. For example: (%i387) f(0,0,0); (x - 1) x (y - 1) y (z - 1) z (%o387) ----------------------------- 8 Yet, if the expression's variables are substituted in the function declaration then everything works as expected: (%i388) f(b,c,d) := subst([x=b,y=c,z=d],a); (%o388) f(b, c, d) := subst([x = b, y = c, z = d], a) (%i389) f(0,0,0); (%o389) 0 That extra call to subst() should not be needed in order to successfully declare a function from an expression. ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2010-01-11 00:54 Message: Yes, that is the expected behaviour. The operator := does not evaluate its argument. (%i18) a:((x - 1)*x*(y - 1)*y*(z - 1))*z/8\$ If you use the symbol a in the definition, you get a function which is defined to return the symbol a or the value of the symbol a. (%i20) f(x,y,z):=a; (%o20) f(x,y,z):=a You have to double-quote the symbol a to insert the value of a: (%i21) f(x,y,z):=''a; (%o21) f(x,y,z):=(x-1)*x*(y-1)*y*(z-1)*z/8 Again, using the double-quoted %-operator: (%i26) a; (%o26) (x-1)*x*(y-1)*y*(z-1)*z/8 (%i27) f(x,y,z):=''%; (%o27) f(x,y,z):=(x-1)*x*(y-1)*y*(z-1)*z/8 Closing this bug report as invalid. Dieter Kaiser ---------------------------------------------------------------------- Comment By: Rui Maciel (rui_maciel) Date: 2009-12-30 11:40 Message: That's weird. It appears it works with the define() function but if the := operator is used directly then the function definition fails. For example: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x - 1)*x*(y - 1)*y*(z - 1))*z/8; (%i2) f(x,y,z) := %; (%o2) f(x, y, z) := % (%i3) f(0,0,0); (%o3) f(x, y, z) := % (%i4) define(f(x,y,z), %o1); (%o4) f(x, y, z) := ((x - 1)*x*(y - 1)*y*(z - 1)*z)/8 (%i5) f(0,0,0); (%o5) 0 Is this a bug or is this behaviour expected? ---------------------------------------------------------------------- Comment By: Aleksas Domarkas (alex108) Date: 2009-12-30 06:56 Message: You can successfully declare a function from an expression: (%i1) (x - 1)*x*(y - 1)*y*(z - 1)*z/8; (%o1) ((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i2) define(f(x,y,z),%); (%o2) f(x,y,z):=((x-1)*x*(y-1)*y*(z-1)*z)/8 (%i3) f(0,0,0); (%o3) 0 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2922933&group_id=4933 ```