Subject: mailing-list for TeXmacs Users
List archive
From : Kyle Andrews <address@hidden>- To: "address@hidden" <address@hidden>
- Subject: [TeXmacs] style sheet language value typing
- Date: Sat, 4 Aug 2018 00:40:36 -0400
Dear TeXmacs users,
I am trying to learn the style sheet language by implementing a simple macro called nth. The goal of this macro is to transform 1 and 1st, 2 into 2nd, 3 into 3rd, and 4 into 4th, and so on. The code is shown below.
<assign|last-character|<macro|expr|<with|n|<length|<arg|expr>>|<range|<arg|expr>|<minus|<value|n>|1>|<value|n>>>>>
<assign|nth|<macro|n|<with|d|<last-character|<arg|n>>|<case|<equal|<arg|d>|1>|<arg|n><rsup|st>|<equal|<arg|d>|2>|<arg|n><rsup|nd>|<equal|<value|d>|3>|<arg|n><rsup|rd>|<arg|n><rsup|th>>>>>
It seems like it should work, but I'm missing something fundamental in my understanding about how the style sheet macro language does value typing. I tried taking <minus|5|<last-character|42>>, and got <error|bad plus/minus>. When I tried to compare equality, I got false. Clearly these things are being interpreted by the parser in a way I don't understand.
I tried searching for some documentation about this kind of thing in the manual, but so far haven't had any luck. I would appreciate any pointers from the community.
Best Regards,
Kyle
P.S.
Here is a nicer scheme-like representation fo the macro code:
(document
(assign "last-character"
(macro "expr"
(with "n" (length (arg "expr"))
(range (arg "expr")
(minus (value "n") "1")
(value "n")))))
(assign "nth"
(macro "n"
(with "d" (last-character (arg "n"))
(case (equal (arg "d") "1") (concat (arg "n") (rsup "st"))
(equal (arg "d") "2") (concat (arg "n") (rsup "nd"))
(equal (value "d") "3") (concat (arg "n") (rsup "rd"))
(concat (arg "n") (rsup "th")))))))
(assign "last-character"
(macro "expr"
(with "n" (length (arg "expr"))
(range (arg "expr")
(minus (value "n") "1")
(value "n")))))
(assign "nth"
(macro "n"
(with "d" (last-character (arg "n"))
(case (equal (arg "d") "1") (concat (arg "n") (rsup "st"))
(equal (arg "d") "2") (concat (arg "n") (rsup "nd"))
(equal (value "d") "3") (concat (arg "n") (rsup "rd"))
(concat (arg "n") (rsup "th")))))))
- [TeXmacs] style sheet language value typing, Kyle Andrews, 08/04/2018
- <Possible follow-up(s)>
- Re: [TeXmacs] style sheet language value typing, Takama M., 08/05/2018
- Re: [TeXmacs] style sheet language value typing, Kyle Andrews, 08/06/2018
- Re: [TeXmacs] style sheet language value typing, Kyle Andrews, 08/11/2018
- [TeXmacs] Need help for using String-replace, Bertrand BRATSCHI, 08/23/2018
- Re: [TeXmacs] style sheet language value typing, Kyle Andrews, 08/11/2018
- Re: [TeXmacs] style sheet language value typing, Kyle Andrews, 08/06/2018
Archive powered by MHonArc 2.6.19.