emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Henrik Frisk <frisk.h@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Newbie question
Date: Wed, 1 Aug 2018 16:07:37 +0200	[thread overview]
Message-ID: <CAO0LSb6Vafi4h4TTFDigevyOMxEqKjV9wDRXPg=PwNPVTCMWaA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]

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 <<alist>>)

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 <<chromatic()>>)

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

[-- Attachment #2: Type: text/html, Size: 3186 bytes --]

             reply	other threads:[~2018-08-01 14:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 14:07 Henrik Frisk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-02-08 12:50 Newbie question Ken
2013-02-08 13:15 ` Julian Burgos
2013-02-08 15:50   ` Ken
2013-02-08 15:12 ` Nick Dokos
2009-05-11 17:01 Newbie Question Tennis Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO0LSb6Vafi4h4TTFDigevyOMxEqKjV9wDRXPg=PwNPVTCMWaA@mail.gmail.com' \
    --to=frisk.h@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).