home | news | discuss | issues | license LURE: str |
|
---|---|
home | news | discuss | issues | license LURE: str |
|
tim@menzies.us |
local the=require "config"
local LST=require "lists"
|
Priting Short cutsShort hand for string.format( |
local function fmt(control, ...)
return string.format(control, unpack{...}) end
|
Shorthand for io.write(string.format( |
local function say(control, ...)
return io.write(string.format(control, unpack{...})) end
|
As above, but add a new line |
local function sayln(control, ...)
return io.write(string.format(control.."\n", unpack{...})) end
|
Apply a format to a list off items |
local function fmts(control, t)
return table.concat(
LST.collect(t,function (_)
return string.format(control, _) end),",") end
|
Cull chars from a list |
local function replace_char(pos, str, r)
return str:sub(1, pos-1) .. r .. str:sub(pos+1) end
|
External interface |
return {say=say,fmt=fmt,fmts=fmts,sayln=sayln,replace_char=replace_char}
|
LegalLURE, Copyright (c) 2017, Tim Menzies All rights reserved, BSD 3-Clause License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|