From mboxrd@z Thu Jan 1 00:00:00 1970 From: Henrik Frisk Subject: Newbie question Date: Wed, 1 Aug 2018 16:07:37 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008ea1920572603714" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkrmv-0004n5-La for emacs-orgmode@gnu.org; Wed, 01 Aug 2018 10:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkrmu-00022a-II for emacs-orgmode@gnu.org; Wed, 01 Aug 2018 10:07:41 -0400 Received: from mail-it0-x234.google.com ([2607:f8b0:4001:c0b::234]:52930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkrmu-00021r-C6 for emacs-orgmode@gnu.org; Wed, 01 Aug 2018 10:07:40 -0400 Received: by mail-it0-x234.google.com with SMTP id d9-v6so9771671itf.2 for ; Wed, 01 Aug 2018 07:07:39 -0700 (PDT) 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@gnu.org --0000000000008ea1920572603714 Content-Type: text/plain; charset="UTF-8" Hi, I'm new with Scheme and new with org babel so excuse me if I am missing something obvious. I have this bit of (simplified) Scheme code to generate a list of lists: #+name: chromatic #+begin_src scheme :noweb yes (map (lambda (x) (cond ((< x 4) (list 0 1)) ((equal? x 4) (list 2 0)) ((> x 4) (list 1 1)))) (list 0 1 2 3 4 5 6 7 8 9 10 11)) #+end_src It appears to be working fine outputting a table such as #+RESULTS: | 0 | 1 | | 0 | 1 | | 0 | 1 | ... For another function in Lilypond, also in scheme I need it to be a (list (list 0 1) (list 0 1)...) as in the variable seq below: #+begin_src scheme :noweb yes $(let ((random-state (seed->random-state (current-time))) (seq (list (list 0 0) (list 0 1/2) (list 1 0) (list 1 1/2) (list 2 0) (list 3 0) (list 3 1/2) (list 4 0) (list 4 1/2) (list 5 0) (list 5 1/2) (list 6 0)))) (make-sequential-music (map (lambda (x p) (let ((idx (random 12 random-state))) (make-music 'NoteEvent 'duration (ly:make-duration 2 0 1/1) 'pitch (ly:make-pitch 0 (car p) (car (cdr p)))))) (make-list (length seq)) seq))) #+end_src I can do: (seq <>) if alist is: #+name: alist #+begin_src scheme (list (list 0 0) (list 0 1/2) (list 1 0) (list 1 1/2) (list 2 0) (list 3 0) (list 3 1/2) (list 4 0) (list 4 1/2) (list 5 0) (list 5 1/2) (list 6 0)) #+end_src but what I would like to be able to do is to have have the noweb reference be to the 'chromatic' function above as in: (seq <>) but that doesn't work. Maybe what I am trying to do is not possible, maybe there is a limitation on ob-lilypond, but it seems to me that the result of my function chromatic above spits out ((0 1) (0 1)... ) and that this is the cause it doesn't work. Again, I am really new to this... The workaround I am doing is to format the output of chromatic into a proper list och lists and then add it by noweb reference. Any hints welcome. /Henrik --0000000000008ea1920572603714 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I'm new with Scheme and new wit= h org babel so excuse me if I am missing something obvious.
I hav= e this bit of (simplified) Scheme code to generate a list of lists:

=C2=A0 =C2=A0 #+name: chromatic
=C2=A0 =C2= =A0 #+begin_src scheme :noweb yes=C2=A0
=C2=A0 =C2=A0 =C2=A0 (map= (lambda (x)=C2=A0
=C2=A0= =C2=A0 =C2=A0(cond ((< x 4) (list 0 1))
=C2=A0 =C2=A0((equal? x 4) (list 2 0))
=C2=A0 =C2=A0((> x 4) (list 1 1))))
=C2=A0 =C2=A0(list 0 1 2 3= 4 5 6 7 8 9 10 11))
=C2=A0 =C2=A0 #+end_src

=
It appears to be working fine outputting a table such as=C2=A0

=C2=A0 =C2=A0 #+RESULTS:=C2=A0
=C2= =A0 =C2=A0 | 0 | 1 |
=C2=A0 =C2=A0 | 0 | 1 |
=C2=A0 =C2= =A0 | 0 | 1 |
=C2=A0...

For anothe= r function in Lilypond, also in scheme I need it to be a (list (list 0 1) (= list 0 1)...) as in the variable seq below:

= =C2=A0#+begin_src scheme :noweb yes
=C2=A0$(let ((random-state (s= eed->random-state (current-time)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0= (seq (list (list 0 0) (list 0 1/2) (list 1 0) (list 1 1/2) (list 2 0) (list= 3 0) (list 3 1/2) (list 4 0) (list 4 1/2) (list 5 0) (list 5 1/2) (list 6 = 0))))
=C2=A0 =C2=A0(make-sequential-music=C2=A0
=C2=A0 = =C2=A0 (map (lambda (x p)=C2=A0
= =C2=A0 =C2=A0(let ((idx (random 12 random-state)))=C2=A0
<= span style=3D"white-space:pre"> =C2=A0 =C2=A0 =C2=A0(make-music '= ;NoteEvent=C2=A0
'= duration (ly:make-duration 2 0 1/1)=C2=A0
'pitch (ly:make-pitch 0 (car p) (car (cdr p))))))
=C2=A0 =C2=A0(make-list (l= ength seq)) seq)))
=C2=A0 =C2=A0 =C2=A0#+end_src
=
I can do:

(seq <<alist>>= ;)

if alist is:

=C2= =A0 =C2=A0 #+name: alist
=C2=A0 =C2=A0 #+begin_src scheme
=C2=A0 =C2=A0 =C2=A0 (list (list 0 0) (list 0 1/2) (list 1 0) (list 1 1/= 2) (list 2 0) (list 3 0) (list 3 1/2) (list 4 0) (list 4 1/2) (list 5 0) (l= ist 5 1/2) (list 6 0))
=C2=A0 =C2=A0 #+end_src
but what I would like to be able to do is to have have the now= eb reference be to the 'chromatic' function above as in:
=
(seq <<chromatic()>>)

b= ut that doesn't work. Maybe what I am trying to do is not possible, may= be there is a limitation on ob-lilypond, but it seems to me that the result= of my function chromatic above spits out ((0 1) (0 1)... ) and that this i= s the cause it doesn't work.

Again, I am reall= y new to this...

The workaround I am doing is to f= ormat the output of chromatic into a proper list och lists and then add it = by noweb reference.

Any hints welcome.
/= Henrik
--0000000000008ea1920572603714--