Shorthand if()?
1
Name:
Anonymous
2008-05-06 4:39
sup /prog/ ,
I was wondering whether any of you would use in lieu of
if(cond)
do_something();
the equivalent
cond && do_something();
or something like this for a function that returns 0 on error:
(s=get_foo()) || fprintf(stderr,"Error getting foo\n");
of course, multiline if-statements would be a bad idea with this, but how about if statements with a single body statement?
2
Name:
Anonymous
2008-05-06 4:40
no
3
Name:
Anonymous
2008-05-06 4:49
well i think gcc supports terniary ? thing with no else clause.
4
Name:
Anonymous
2008-05-06 5:09
It doesn't work if
do_something returns void, and it feels kinda silly to change to a different construct based on the return type of the then-clause.
>>3
What...
why ? Don't they like `if'?
5
Name:
Anonymous
2008-05-06 6:57
(when cond (do_something))
Fuck "if" if there's no "else" clause.
6
Name:
Anonymous
2008-05-06 7:35
>>3
foo ? expr : (void)0;
7
Name:
Anonymous
2008-05-06 7:47
>>1
I do it all the time. It's called Perl.
8
Name:
Anonymous
2008-05-06 7:52
for(;cond;){do_something(); break;}
9
Name:
Anonymous
2008-05-06 10:06
if me.hasanus()
hax(me)
else
hax(your.getanus())
10
Name:
Anonymous
2008-05-06 10:09
__ __ __ __ ____ ___ _________________________________________
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2003
||---|| ___|| World Wide Web: http://haskell.org/hugs
|| || Report bugs to: hugs-bugs@haskell.org
|| || Version: November 2003 _________________________________________
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
11
Name:
Anonymous
2008-05-06 10:50
>>9
me your
Please learn English.
12
Name:
Anonymous
2008-05-06 11:53
Please upgrade,
>>10 .
% ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
'-._ ___.....___
`.__ ,-' ,-.`-,
`''-------' ( p ) `._
`-' ( Have you read your YAHT today?
\
. \
\---..,--'
................._ --...--,
`-.._ _.-'
`'-----'' Type :ihbt for help.
Prelude>
13
Name:
Anonymous
2008-05-06 12:05
>>12
I've been wanting to do it for over a week, but I have a fresh Ubanto install and I can't be bothered to download libs needed to make GHC 6.8.
14
Name:
Anonymous
2008-05-06 12:12
. . ,.".".'"""..
. ,__\.~~
. ;'``` '`` \!"
. `. \~"
.., ' ____________|'~"
`. .__/ |_| |\
`..' | = / | = ||
| \___/ |\___|/
| _| |
\ __ |
\ /__\ ./
|`'._____.'|
/| /\
/ update your \
fucking GHC,
>>13
15
Name:
Anonymous
2008-05-06 12:26
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8
Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2006
16
Name:
Anonymous
2008-05-06 12:32
17
Name:
Anonymous
2008-05-06 12:34
18
Name:
Anonymous
2008-05-06 12:46
>>13
Are you still using Gutsy? Hardy comes with GHC 6.8.2.
19
Name:
Anonymous
2008-05-06 13:57
&do_something if cond;
or
cond and &do_something;
20
Name:
Anonymous
2008-05-06 13:59
>>19
Disregard the second one, I suck cocks.
statement and &do_something;
Fixed.
21
Name:
Anonymous
2008-05-06 14:43
>>18
It also comes with Firefox
3 beta .
22
Name:
Anonymous
2008-05-06 14:45
>>21
You mean it comes with
the best fucking version of Firefox
ever .
23
Name:
Anonymous
2008-05-06 14:46
>>22
That happens to
disable an average of 42,8571429% of an extension ?
24
Name:
Anonymous
2008-05-06 14:51
>>23
Maybe it
disables them because they're
incompatible , so the developers of the extensions should
port them.
25
Name:
Anonymous
2008-05-06 15:04
>>23
One word,
Nightly Tester Tools .
Thread
OVER .
26
Name:
Anonymous
2008-05-06 15:11
Are you guys still using the legacy Firefox 2? I have used Firefox 3 for the last two years.
27
Name:
Anonymous
2008-05-06 15:19
>>26
You're still using Firefox 3? Get the mozilla-central Fx4 builds.
28
Name:
Anonymous
2008-05-06 15:29
>>27
Yeah, I'm actually using the 04-04 Firefox beta ;__;
I should get myself a PKGBUILD that instead downloads the latest nightly tarball like I used to do, but first I'll have to make sure everything is put in /usr and not /opt.
29
Name:
Anonymous
2008-05-07 5:26
int _ = 8==D ;
for (;_;) {_--; Bo( );}
30
Name:
Anonymous
2008-05-07 7:47
>>29
Don't run this code! It's obvious just by looking at it that it will hax your anus.
31
Name:
Anonymous
2008-05-07 9:09
|\|\
|_ _\
|___/
| | r SIGH, it doesn't even compile
| |_____|
SIGH SIGHSIGHSIGH
32
Name:
Anonymous
2008-05-07 9:12
how do I forkbomb in Haskell?
33
Name:
Anonymous
2008-05-07 9:17
>>32
import Control.Concurrent
f = do a <- forkIO g
b <- forkIO g
putStrLn $ "f(): Forked a: " ++ (show a) ++ " and b: " ++ (show b)
return ()
g = do a <- forkIO f
b <- forkIO f
putStrLn $ "g(): Forked a: " ++ (show a) ++ " and b: " ++ (show b)
return ()
some dumbass submitted a bug:
http://hackage.haskell.org/trac/ghc/ticket/1146
34
Name:
Anonymous
2008-05-07 9:21
Isn't there a simpler way using system ?
35
Name:
Anonymous
2008-05-07 9:53
import Control.Concurrent
main = forkIO main >> forkIO main
36
Name:
Anonymous
2008-05-07 11:15
print "Fuck you OP" || die();
print "HAX MY ANUS" && print "HAX MY ANUS";
VALID PERL CODE
37
Name:
Anonymous
2008-05-08 18:43
>>36
He's right you know.
38
Name:
Anonymous
2009-03-06 8:32
The device seeks not to conquer the human nor to be conquered by.
39
Name:
Anonymous
2011-02-27 11:10
> Test
40
Name:
Anonymous
2011-02-27 11:13
> > > > Okay
Newer Posts