• #### Math operation abstraction

From Daniel Cerqueira@21:1/5 to All on Mon May 27 23:29:56 2024
Hi.

I have this function

```
(defun muo (func a b)
(cond
((eq b 1) a)
(t (funcall func a (muo func a (1- b))))))
```

Which I can use for obtaining the multiplication operation using the

* (muo #'+ 5 2)
10

and "muo #'+" means "use the multiplication".

Now if I want the exponentiation I have to do:

* (muo #'(lambda (a b) (muo #'+ a b)) 5 2)
25

This creates the exponentiation.

I would like to obtain the exponentiation using "(muo #'+ 5 2 2)"
instead, being the last argument ("2") the number of times the operation
is applied. In the case of exponentiation, it applies the multiplication
2 times, resulting in the exponentiation math operation.

I am hoping I am explaining this concept well enough.

Basically, "muo #'+" creates the addition twice, which is the
multiplication, and "muo #'+ a b 2" should create the multiplication
twice, which is the exponentiation. If I use "muo #'+ a b 3" it should
create the exponentiation twice, which is the exponentiation of the exponentiation.

I need help in making this code modification. Seeing code is what I
want. If you can write the code and explain it, better.

--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
• From B. Pym@21:1/5 to Daniel Cerqueira on Mon May 27 23:54:43 2024
On 5/27/2024, Daniel Cerqueira wrote:

* (muo #'(lambda (a b) (muo #'+ a b)) 5 2)

Pascal Bourguignon wrote:

#'(lambda (letter)
word))

(function (lambda ...)) is a pleonasm. lambda is a macro that
already expands to (function (lambda ...)).

--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)