Re: Scheme coding: 'number' cases vs 'string' cases
Schneidy wrote What am I missing? Hi Pierre, case doesn't work with strings, so you'd need to use cond instead. Cheers, -Paul -- View this message in context: http://lilypond.1069038.n5.nabble.com/Scheme-coding-number-cases-vs-string-cases-tp174287p174294.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Scheme coding: 'number' cases vs 'string' cases
On Thu, Apr 9, 2015 at 12:48 PM, tisimst tisimst.lilyp...@gmail.com wrote: Pierre, Following Paul's advice, here's working code (which you probably already figured out, but just for the record). Note that you must use equal? for comparisons since it's the only one suited for strings: You could also use the string-specific string=? --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Scheme coding: 'number' cases vs 'string' cases
2015-04-09 18:36 GMT+02:00 Pierre Perol-Schneider pierre.schneider.pa...@gmail.com: Hi List, hi Schemers, I'm currently working on finding new tools to ease drawings with the 'path' command. I already found some nice ones that helped me to create new drawings and enhanced old snippets. That's what I've done here: http://lsr.di.unimi.it/LSR/Item?id=904 However, I'm not satisfied with the code I'm using there; here's roughly how it's working: \version 2.18.2 %% hereunder works fine: #(define-markup-command (smiley layout props smiley-choice) (number?) (interpret-markup layout props (case smiley-choice ((1) #{ \markup A #}) ((2) #{ \markup smile #}) (else #{ \markup \null #}) ))) %% Test: \markup\column { \smiley #1 \smiley #2 \smiley #10 } %% But I think It would be much better to use: #(define-markup-command (smiley-string layout props smiley-choice) (string?) (interpret-markup layout props (case smiley-choice ((A) #{ \markup A #}) ((:)) #{ \markup smile #}) (else #{ \markup \null #}) ))) %% Test: \markup\column { \smiley-string #A \smiley-string #:) \smiley-string #none } %%% ... does not work though. What am I missing? Thank you in advance, Cheers, Pierre See this recent thread on -devel http://lilypond.1069038.n5.nabble.com/banter-style-from-chord-names-jazz-ly-broken-case-problem-td174207.html Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Scheme coding: 'number' cases vs 'string' cases
Hi List, hi Schemers, I'm currently working on finding new tools to ease drawings with the 'path' command. I already found some nice ones that helped me to create new drawings and enhanced old snippets. That's what I've done here: http://lsr.di.unimi.it/LSR/Item?id=904 However, I'm not satisfied with the code I'm using there; here's roughly how it's working: \version 2.18.2 %% hereunder works fine: #(define-markup-command (smiley layout props smiley-choice) (number?) (interpret-markup layout props (case smiley-choice ((1) #{ \markup A #}) ((2) #{ \markup smile #}) (else #{ \markup \null #}) ))) %% Test: \markup\column { \smiley #1 \smiley #2 \smiley #10 } %% But I think It would be much better to use: #(define-markup-command (smiley-string layout props smiley-choice) (string?) (interpret-markup layout props (case smiley-choice ((A) #{ \markup A #}) ((:)) #{ \markup smile #}) (else #{ \markup \null #}) ))) %% Test: \markup\column { \smiley-string #A \smiley-string #:) \smiley-string #none } %%% ... does not work though. What am I missing? Thank you in advance, Cheers, Pierre ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Scheme coding: 'number' cases vs 'string' cases
Thank you all very much!! I'll keep your precious advices in my scheme-tool-box. @Harm: I'll take a deeper look in 'list' and its associations @Paul: you're wright, that's exactly what I was missing. @Abraham: I'll use your snippet! @David: I'll use 'string=?' since I never used it before, better for my memory. Problem solved! Cheers, Pierre ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Scheme coding: 'number' cases vs 'string' cases
Pierre, Following Paul's advice, here's working code (which you probably already figured out, but just for the record). Note that you must use equal? for comparisons since it's the only one suited for strings: %-- SNIP -- #(define-markup-command (smiley-string layout props smiley-choice) (string?) (interpret-markup layout props (cond ((equal? smiley-choice A) #{ \markup A #}) ((equal? smiley-choice :)) #{ \markup smile #}) (else #{ \markup \null #}) ))) %% Test: \markup\column { \smiley-string #A \smiley-string #:) \smiley-string #none } %-- SNIP -- - Abraham On Thu, Apr 9, 2015 at 11:40 AM, Paul Morris [via Lilypond] ml-node+s1069038n174294...@n5.nabble.com wrote: Schneidy wrote What am I missing? Hi Pierre, case doesn't work with strings, so you'd need to use cond instead. Cheers, -Paul -- If you reply to this email, your message will be added to the discussion below: http://lilypond.1069038.n5.nabble.com/Scheme-coding-number-cases-vs-string-cases-tp174287p174294.html To start a new topic under User, email ml-node+s1069038n...@n5.nabble.com To unsubscribe from Lilypond, click here http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2code=dGlzaW1zdC5saWx5cG9uZEBnbWFpbC5jb218Mnw4MzU3Njg3MDU= . NAML http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://lilypond.1069038.n5.nabble.com/Scheme-coding-number-cases-vs-string-cases-tp174287p174295.html Sent from the User mailing list archive at Nabble.com.___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user