# Function behavior based on Head

I'm figuring how to implement a function behavior based on the Head of its argument.

I mean

Unprotect@Head;
function[h_]:= 0;
function[p_Kind]:= 1;

function[f[x]]
function[f]


the first instance of function should evaluate to 1 whereas the second instance should evaluate to 0. However, both evaluate to 0. Notice that Head[f[x]] evaluate to Kind as expected.

Where am I doing mistake(s)?

Thank you very much

-
Try function[p_ /; Head@p === Kind] := 1; –  rasher Mar 21 at 8:10
@rasher Thank you now it works. –  Fabio Mar 21 at 8:19
@kuba your solution failed though I expected it works too... strange –  Fabio Mar 21 at 8:20
Yes, but pay heed to Kuba's comment - in general, doing things requiring Unprotect on system stuff is either not required, a bad idea, or both. There are times when that's the only viable way, but there's usually a better/cleaner/safer way. –  rasher Mar 21 at 8:21
I didn't say it will work. This was about Unprotecting important things ;) I've deleted my comment because I find myself a newbie in internals so let's wait for someone competent. @Rasher's solution works but I think it's not how one may want to do this. –  Kuba Mar 21 at 8:25