Thorsten Jolitz <tjol...@gmail.com>
writes:

Hi List,

> This comes pretty close to what I was looking for, thanks. The only
> drawback is that normal parens (and double quotes) are very common in
> text so a lot of escaping would be necessary. Something like this:
>
>    (g Current "temperature" in Berlin is {Temp} \{°Celsius\} (its
>    really hot!) )
>
> resulting in:
>
> -> "Current \"temperature\" in Berlin is 33 {°Celsius} (its really hot!)"
>
> would be much more comfortable as syntax, but harder to implement.

I implemented something close to my goal, with $xyz$ syntax for
arguments to be evaluated:

,----
| (de f Args
|       (mapcar
|          '((Arg)
|            (if (atom Arg)
|               (let (ChopArgs (chop Arg)
|                     ArgsTail (tail 2 ChopArgs)
|                     PunctChars (chop ".,;:?!\"'_-{[]}" )
|                     ArgLst NIL
|                     Punct NIL )
|                  (ifn (and
|                         (= (car ChopArgs) "$")
|                         (or
|                            (= (last ChopArgs) "$")
|                            (and
|                               (= (car ArgsTail) "$")
|                               (member (last ArgsTail) PunctChars)
|                               (setq Punct (last ArgsTail))
|                               (setq ChopArgs (head -1 ChopArgs)
|                                  ) ) ) )
|                     Arg
|                     (pack
|                        (val
|                           (intern
|                              (pack
|                                 (tail -1 (head -1 ChopArgs)) ) ) )
|                        Punct ) ) )
|               (f Arg) ) ) # use recur/recurse instead?
|           Args ) )
`----

using it returns an almost perfect list result:

,----
| (setq
|    D1 (date 1999 09 09)
|    D2 (date 2000 03 04) 
|    T1 (time 20 12 05)
|    T2 (time 18 03 03)
|    S1 (stamp D1 T1)
|    S2 (stamp D2 T2) )
| 
| (f Is $S1$ before $S2$?
|    The answer is
|    `(if (and
|            (<= $D1$ $D2$)
|            (<= $T1$ $T2$) )
|        "Yes"
|        "No" ) )
| 
| 
| -> (Is "1999-09-09 20:12:05" before "2000-03-04 18:03:03?" The answer is 
"Yes")
`----

only that

  "2000-03-04 18:03:03?"

should rather be

 "2000-03-04 18:03:03"?

I did not yet make it to write a function g in the spirit of:

,----
| (de g Args
|   (glue " " (f Args)) ) # does not work
`----

that then returns a single string:


,----
| "Is \"1999-09-09 20:12:05\" before \"2000-03-04 18:03:03\"? The answer is 
\"Yes\""
`----


-- 
cheers,
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to