Language 84

File

language84-0.4/string.84

{
: append
: concat
: join
: equal
: length
: fetch
: clip
: compare
}

Where

Define (join glue strings)
    Match strings
    | 'nil ""
    | 'cons.{s strings}
        Let strings
            (LIST.fold strings 'nil
                Func {s strings} [Right glue & s & strings])
        In
        (concat [s & strings])
    ;

Where

Define (concat strings) (LIST.reduce strings "" append)

Where

Define (compare a b)
    Let sign (Prim string_compare a b)
    In
    Cond
    | [sign = -1] 'less
    | [sign = 0] 'equal
    | [sign = 1] 'greater
    ;

Define (append s1 s2)
    (Prim string_append s1 s2)

Define (equal s1 s2)
    (Prim string_equal s1 s2)

Define (length s)
    (Prim string_length s)

Define (fetch s i)
    (Prim string_fetch s i)

Define (clip s begin end)
    (Prim string_clip s begin end)

Where

Let LIST Package "list"