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

« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total

translit string (americanize)

require 'iconv'

class String
  def translit
    self.gsub(/[^\x20-\x7f]/){ Iconv.iconv('us-ascii//IGNORE//TRANSLIT', 'utf-8',$&)[0].sub(/^[\^`'"~](?=[a-z])/i, '')}
  end
end

pull function

    pull: func [
        "Remove and return items from a series."
        series [series! none!]
        /part "The number of items to pull; one is the default"
            range [number!]
        /local result
    ] [
        if none? series [return none]
        result: either part [copy/part series range] [pick series 1]
        either part [remove/part series range][remove series]
        result
    ]
    comment {
        b: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
        pull b
        pull/part b 2
        pull/part at b 3 10
        pull at b 14
    }
« Newer Snippets
Older Snippets »
Showing 11-12 of 12 total