[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [FUN] A bit of code golfing
- From: "Soni L." <fakedme@...>
- Date: Wed, 28 Sep 2016 18:28:21 -0300
On 28/09/16 06:20 PM, Egor Skriptunoff wrote:
I have a small programming problem for you to solve, just for fun.
Your task is to implement string-based function NVL(x,y) in Lua.
Both arguments of NVL are always strings.
NVL returns its first argument if it is not empty string, otherwise it
returns its second argument.
assert(NVL("Hello", "World") == "Hello")
assert(NVL("", "Lua") == "Lua")
An example of implementation:
function NVL(x,y)return x==""and y or x end
The length of source code of this implementation is 43 bytes.
Your task is to fit your implementation in smaller size.
NVL seems to be a simple stupid function, but nevertheless it can be
I have two different solutions: 42 and 41 bytes. Try to find either
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.