Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

single-line-reformat - Reformats a block/object to a single line if it's short enough (See related posts)

    single-line-reformat: func [
        "Reformats a block/object to a single line if it's short enough."
        val [any-string!] /local s map
    ] [
        either 80 >= length? s: trim/lines copy val [
            map: ["{ " "{"  "[ " "["  " }" "}"  " ]" "]"]
            foreach [from to] map [replace s from to]
        ] [val]
    ]

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts