From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Berry, Charles" Subject: Re: Calling/using named babel code blocks Date: Wed, 18 Dec 2019 18:03:07 +0000 Message-ID: <04992615-0914-48C0-BA3C-EA2DD175D8DF@ucsd.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:55018) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihdfw-0008O4-GR for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 13:03:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihdfu-0006vX-U7 for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 13:03:55 -0500 Received: from mx0b-00395d01.pphosted.com ([148.163.137.170]:9686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ihdfu-0006kx-3x for emacs-orgmode@gnu.org; Wed, 18 Dec 2019 13:03:54 -0500 In-Reply-To: Content-Language: en-US Content-ID: <9DF67B231F285A468278EA9C71593B55@AD.UCSD.EDU> 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: Lawrence Bottorff Cc: emacs-orgmode Mailinglist > On Dec 18, 2019, at 9:10 AM, Lawrence Bottorff wrote: >=20 > I thought I understood "metaprogramming," i.e., creating generic code blo= cks that can be called by any other code block regardless of programming la= nguage -- but apparently I don't. I have this >=20 > #+name: my-random-gen > #+header: :var n=3D0 :var lim=3D0 > #+BEGIN_SRC emacs-lisp > (loop repeat n collect (random* lim)) > #+END_SRC >=20 > 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 >=20 > #+BEGIN_SRC emacs-lisp > my-random-gen(5 1.0) > #+END_SRC >=20 > and this various versions of this >=20 > #+BEGIN_SRC emacs-lisp :var results=3Dmy-random-gen() :var n=3D5 :var lim= =3D1.0 > results > #+END_SRC >=20 > to no avail. What am I missing? How can I actually use, call my-random-ge= n in other code blocks? >=20 Do these help? #+BEGIN_SRC emacs-lisp :noweb yes '<> #+END_SRC #+BEGIN_SRC emacs-lisp :var mrg=3Dmy-random-gen(5, 1.0) mrg #+END_SRC Chuck