From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: Calling/using named babel code blocks Date: Wed, 18 Dec 2019 11:10:49 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006453ef0599fd879f" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:41651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihcqo-0005Ey-Fd for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 12:11:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihcqm-0006a5-RK for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 12:11:06 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:37177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihcql-0006V9-I3 for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 12:11:04 -0500 Received: by mail-lf1-x12d.google.com with SMTP id b15so2249173lfc.4 for ; Wed, 18 Dec 2019 09:11:02 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode Mailinglist --0000000000006453ef0599fd879f Content-Type: text/plain; charset="UTF-8" I thought I understood "metaprogramming," i.e., creating generic code blocks that can be called by any other code block regardless of programming language -- but apparently I don't. I have this #+name: my-random-gen #+header: :var n=0 :var lim=0 #+BEGIN_SRC emacs-lisp (loop repeat n collect (random* lim)) #+END_SRC and I have the variables initialized to zero. But now I don't know how to call it with another code block. I've tried various versions of this #+BEGIN_SRC emacs-lisp my-random-gen(5 1.0) #+END_SRC and this various versions of this #+BEGIN_SRC emacs-lisp :var results=my-random-gen() :var n=5 :var lim=1.0 results #+END_SRC to no avail. What am I missing? How can I actually use, call my-random-gen in other code blocks? LB --0000000000006453ef0599fd879f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I thought I understood &q= uot;metaprogramming," i.e., creating generic code blocks that can be c= alled by any other code block regardless of programming language -- but app= arently I don't. I have this
=C2=A0#+name: my-random-gen
#+header: :var n=3D0 :var lim=3D0
#+BEGIN_SRC emacs-lisp
(loop re= peat n collect (random* lim))
#+END_SRC

and I = have the variables initialized to zero. But now I don't know how to cal= l it with another code block. I've tried various versions of this
=

#+BEGIN_SRC emacs-lisp
my-random-gen(5 1.0)
#+END_SRC

and this various versions of this

#+BEGIN_SRC emacs-lisp :var results=3Dmy-random-gen() :var n=3D5= :var lim=3D1.0
results
#+END_SRC

to no avail. What am I=C2=A0missing? How can I actually use, call=C2=A0my-random-gen in other code blocks?
=
LB


--0000000000006453ef0599fd879f--