FoscScheme

Returns a FoscScheme.


Description

Scheme

!!!NB:

abjad: Scheme(1, 2, 3, force_quotes=True, verbatim=False)

fosc: FoscScheme(1, 2, 3).forceQuotes_(true).isVerbatim_(false);

Examples from http://abjad.mbrsi.org/api/tools/schemetools/Scheme.html


Attributes Summary

Class Methods

formatEmbeddedSchemeValue Formats value as an embedded Scheme value.
formatSchemeValue Formats value as Scheme would.
makeSpacingVector //!!! DEPRECATE

Instance Methods

forceQuotes_ Is true when quotes should be forced in output.
format
isVerbatim_ Is true when formatting should format value absolutely verbatim. Whitespace,
quoting_ Sets Scheme quoting string.


Usage

  1. A Scheme boolean value

    a = FoscScheme(true);
    a.format;
    ##t
  2. Example 2. A nested Scheme expession

    a = FoscScheme(['left', [1, 2, false]], ['right', [1, 2, 3.3]]);
    a.format;
    #((left (1 2 #f)) (right (1 2 3.3)))
  3. Example 3. A variable-length argument

    Scheme wraps nested variable-length arguments in a tuple.

    a = FoscScheme(1, 2, 3);
    b = FoscScheme([1, 2, 3]);
    format(a) == format(b);
    true
  4. Example 4. A quoted Scheme expression

    a = FoscScheme([1, 2, 3]).quoting_("'#");
    a.format;
    #'#(1 2 3)
  5. Example 5. A Scheme expression with forced quotes

    a = FoscScheme('nospaces').forceQuotes_(true);
    a.format;
    #"nospaces"
  6. Example 6. A Scheme expression of LilyPond functions

    Use this in certain override situations when LilyPond’s Scheme interpreter treats unquoted strings as symbols instead of strings. The string must contain no whitespace for this to work.

    x = "tuplet-number::append-note-wrapper";
    y = "tuplet-number::calc-denominator-text";
    a = FoscScheme("4").forceQuotes_(true);
    b = FoscScheme(x, y, a);
    b.format;
    #(tuplet-number::append-note-wrapper tuplet-number::calc-denominator-text "4")
  7. Example 7. A Scheme lambda expression of LilyPond function that takes a markup with a quoted string argument.

    Setting verbatim to true causes the expression to format exactly as-is without modifying quotes or whitespace:

    x = "(lambda (grob) (grob-interpret-markup grob' #{ \\markup \\musicglyph #\"noteheads.s0harmonic\" #}))";
    a = FoscScheme(x).isVerbatim_(true);
    a.format;
    #(lambda (grob) (grob-interpret-markup grob' #{ \markup \musicglyph #"noteheads.s0harmonic" #}))


Class Methods


formatEmbeddedSchemeValue

Formats value as an embedded Scheme value.

  1. Example

    FoscScheme.formatEmbeddedSchemeValue(FoscOrdinalConstant('x', -1, \left));
    #left


formatSchemeValue

Formats value as Scheme would.

  1. Example

    FoscScheme.formatSchemeValue(1);
    1
    FoscScheme.formatSchemeValue("foo\"bar", isVerbatim: false);
    foo\"bar
    FoscScheme.formatSchemeValue("foo\"bar", isVerbatim: true);
    foo"bar
    FoscScheme.formatSchemeValue("foobar");
    foobar
    FoscScheme.formatSchemeValue('foo bar');
    "foo bar"
    FoscScheme.formatSchemeValue(true);
    #t
    FoscScheme.formatSchemeValue([\one, "two", \three, "four", 5, 7]);
    (one two three four 5 7)
    FoscScheme.formatSchemeValue();
    #f
    FoscScheme.formatSchemeValue("four", forceQuotes: true);
    "four"
    FoscScheme.formatSchemeValue("#1-finger", isVerbatim: true);
    #1-finger
    FoscScheme.formatSchemeValue("#1-finger", isVerbatim: false);
    "#1-finger"
    m = FoscMarkup("\\bold { over pressure }");
    FoscScheme.formatEmbeddedSchemeValue(m);
    \markup { "\bold { over pressure }" }


makeSpacingVector

//!!! DEPRECATE //!!! use FoscSchemeSpacingVector instead

  1. Example

    a = FoscScheme.makeSpacingVector(0, 0, 12);
    a.format;
    #'((basic-distance . 0) (minimum-distance . 0) (padding . 12) (stretchability . 0))


Instance Methods


forceQuotes_

Is true when quotes should be forced in output.


format


isVerbatim_

Is true when formatting should format value absolutely verbatim. Whitespace, quotes, and all other parts of value are left intact.


quoting_

Sets Scheme quoting string.