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

In Mathematica the FullForm of a && b is And[a, b]. You can use this to format long lists of conditions as

    And[
        a,
        b
    ]
You can also rely on the fact that logical expressions are always short-circuited, so False && Print["won't be printed"], doesn't print anything.

Finally, you can put a bunch of conditions in a list and do And @@ list.



> You can also rely on the fact that logical expressions are always short-circuited, so False && Print["won't be printed"], doesn't print anything.

This is true for any language I can think of.

E.g. in perl

    open(my $fh, "<", "input.txt")
        or die "cannot open < input.txt: $!";
is idiomatic




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

Search: