emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library of Babel usage of other programming languages than elisp


From: Greg Minshall
Subject: Re: Library of Babel usage of other programming languages than elisp
Date: Mon, 09 Aug 2021 18:23:23 +0300

Zelphir,

actually...

Everybody,

i have an awkwardness about not being clear of the meaning of "Library
of Babel".  my sense is it a collection of "subroutines".

in my typical use of Org mode for programming, all my code blocks are
defined in the same .org file, and executed in that file, or tangled to
external files (normally, scripts).  i do use <<noweb>> to include bits
from one part of the same file to the code in another part.  i don't
know if this means i am using the Library of Babel or not.

then, on to...

Zelphir,

i also don't know what is going on.  but, installing geiser,
geiser-guile, and running your code from the source block, looking at
the output results, i get an error that might mean something to you?
see below.  (notice i embedded your call to =org-lob-timediff= at the
end of your source code.)

in addition to with elisp, i use org src blocks with R, shell scripts,
awk, etc.  but, never (till now!) with scheme.

hth.  good luck.  i'll be curious what your next steps are.

cheers, Greg
----

#+HEADER: :var dt1="uninitialized1" dt2="uninitialized2"
#+name: org-lob-timediff
#+begin_src scheme :results output
  (import
   (ice-9 format)
   (srfi srfi-19))


  (define org-timestamp->time-utc
    (λ (timestamp-string)
      (let ([parsed-date (string->date timestamp-string "[~Y-~m-~d ~a ~H:~M]")])
            (date->time-utc parsed-date))))


  (define duration->hours
    (λ (duration)
      ;; 1h = 60min = 3600s
      (/ (time-second duration) 3600)))


  (define org-lob-timediff
    (λ (org-dt1 org-dt2)
      ;; formatting float:

      ;; ~@width, decimals, scale, overflowchar, padchar

      ;; ~ placeholder is following
      ;; @ with sign if negative
      ;; width: minimum width
      ;; decimals: minimum number of digits after decimal point
      ;; scale: ???
      ;; overflowchar: ???
      ;; padchar: char to use for padding

      (format #f
              "~,2f"
              (number->string
               (exact->inexact
                (duration->hours
                 (time-difference (org-timestamp->time-utc org-dt2)
                                  (org-timestamp->time-utc org-dt1))))))))
  (org-lob-timediff "[2021-01-01 Fri 00:00]" "[2021-01-01 Fri 01:45]")
#+end_src

#+RESULTS: org-lob-timediff
: ice-9/boot-9.scm:222:17: In procedure map1:
: Syntax error:
: unknown file:12:0: definition in expression context, where definitions are 
not allowed, in form (define org-timestamp->time-utc (λ (timestamp-string) (let 
((parsed-date (string->date timestamp-string "[~Y-~m-~d ~a ~H:~M]"))) 
(date->time-utc parsed-date))))
: 
: Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
: scheme@(guile-user) [1]> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]