Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think you could save time by showing people code like this:

int x=5 % 3

and asking "What is the value of x?" Because a lot of jobs are CRUD and that form of programming rarely involves the modulus operator.



Well, assuming it's Haskell (given the lack of semicolon and otherwise valid Haskell syntax):

x is an unused variable in the function "int" you're defining. This function returns the ratio (as a ratio, not a float) 5 / 3 for any argument, and is equivalent to "int = const (5 % 3)", which you would be more likely to see (probably inlined).


You don't actually need the modulus operator, although it makes things simpler. Just use (x/3)*3==x instead.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: