Unless the challenge explicitly asks for a named function unnamed functions are completely legitimate. That means you don't count the assignment either. So your example
f=x=>x
would be four bytes, and I wouldn't even include f=
in the post, so that it's clear how I've counted.
What if there are two functions? That depends. If the questions actually asks for two functions (e.g. a decoder and an encoder), count them separately just like you would count a single function. This means that neither assignment would be counted. For instance, if your two submissions were
f=x=>x*x
g=x=>sqrt(x)
I'd count that as 6 + 10 = 16
. Again I would not actually write f=
and g=
in the post.
However, if you define one function to be used in another, like you did in your example, then the first assignment definitely needs to be counted. Your f
wouldn't work without the assignment, because it references g
by name. So I would count the assignment to g
but not the assignment to f
. I would present the solution like this:
g=x=>x/2
x=>g(x)+g(x)
and therefore count it as 21 bytes.
Likewise, if a function is recursive, you must also count the assignment:
f=x=>x&&f(x-1)
Would count as 14 bytes since the function wouldn't work unless f
was defined.