Haskell, 26 bytes
f(x:y)=([x],0)*>span(/=x)y Shortens Zgarb's OG solution
f(x:y)|(a,b)<-span(/=x)y=(x:a,b) by prepending x to the first element of (a,b) in a pointfree way, that is without explicitly binding (a,b). Unfortunately,
It would be nice it we could do (x:)<$>(a,b) only, but that gives us (a,x:b) -- the Functor instance of tuples lets us act on the second element but not the first.
ButHowever, Applicative lets us combine tuples as:
(p, f) <*> (a, b) = (p++a, f b) ([x], id) <*> (a, b) = (x:a, b) It suffices to use *> which ignores f and leaves b unchanged.
((x:), 0) *> (a, b) = (x:a, b) The 0 could be anything -- it doesn't matter. It would also work to use >> in place of *>.
26 bytes
f(x:y)=([x],y)>>=span(/=x) A alternative, this time using the Monad instance and (>>=) :: Monoid a => (a, a0) -> (a0 -> (a, b)) -> (a, b)
27 bytes
f(x:y)=([x],[])<>span(/=x)y Using <> to do concatenate elementwise (a, b) <> (c, d) = (a++c, b++d). This is available in Prelude without an import starting in version 8.4.1.