I'm trying to learn how to use the noweb syntax and advance my knowledge on the possibilities of org babel. For that, I'm trying to get the following an example to work that 1. uses noweb syntax and 2. calls the tangled function later on in the code.
Here is the code:
# This is the function that needs to be tangled
#+NAME: fast-multiplication
#+BEGIN_SRC scheme :noweb yes :var a=1 :var b=1
(define (fast-multiplication a b)
<<double>>
<<halve>>
(cond ((= b 0) 0)
((even? b) (fast-multiplication (double a) (halve b)))
(else (+ a (fast-multiplication a (- b 1))))))
#+END_SRC
Now, we'll need procedures for doubling and halving. We can write them down here:
#+NAME: double
#+BEGIN_SRC scheme
(define (double a)
(+ a a))
#+END_SRC
#+NAME: halve
#+BEGIN_SRC scheme
(define (halve a)
(/ a 2))
#+END_SRC
# I couldn't find examples in the documentation to check my syntax.
# I think this line here is wrong..
#+call: fast-multiplication(a=5,b=7)
#+RESULTS:
: "An error occurred."
So I get an error, which I think comes from the way I'm calling the function? Everything works fine if I try it directly on the REPL.