Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Yay, Java!

Name: Anonymous 2008-04-14 2:01

Doing a validator method for RNA complements:

private static boolean isComplementar(final char a, final char b) {
  boolean s1 = (a == 'A' && b == 'U');
  boolean s2 = (a == 'U' && b == 'A');
  boolean s3 = (a == 'C' && b == 'G');
  boolean s4 = (a == 'G' && b == 'C');
  return (s1 || s2 || s3 || s4);
}


LULZ

Name: Anonymous 2008-04-14 2:16

-!- mode/#prog [+b*!*@*faggots.net] byALTERNATIVE
-
!-Anonymous was kicked from#prog byALTERNATIVE   [lulz]

Name: Anonymous 2008-04-14 2:23

Why not set up a Map in a static {} block and just

return b == Map.get(a)

Name: Anonymous 2008-04-14 2:54

>>3
although I've never used interfaces/collections/whatnot, I don't know is that would make it more simpler/faster.

Name: Anonymous 2008-04-14 3:20

isComplementar
Wetback detected

Name: Anonymous 2008-04-14 3:27

>>5

worse, I'm Brazilian >:/

Name: Anonymous 2008-04-14 3:34

int isComplementar(char a, char b) {
 const char c[]="AUCG",d[]="UAGC";
 return (strchr(c,a)-&a)==(strchr(d,b)-&d);
}

Name: Anonymous 2008-04-14 3:37

>>7
Error: Term &d
Expected type: char *
Inferred type: char (*)[5]
In the expression: strchr(d,b) - &d

Name: Anonymous 2008-04-14 3:40

>>8
And so Java imitates fail.

Name: Anonymous 2008-04-14 3:46

return (strchr(c,a)-&a)==(strchr(d,b)-&d);
rchr(c,a)-&a)==(strchr(d
,a)-&a)==(str

&a

Name: Anonymous 2008-04-14 8:02

If you can use a String instead of chars, you could make the valid complements static final. Then the JVM will intern them and you can legitimately do a == comparison to check if it matches.


public static final String s1 = "AU".intern();
public static final String s2 = "UA".intern();
public static final String s3 = "CG".intern();
public static final String s4 = "GC".intern();

private static final boolean isComplementar(String aPlusB) {
  return (aPlusB == s1 || aPlusB == s2 || aPlusB == s3 || aPlusB == s4)
}


Note the .intern() here is redundant, I just included it for clarity.

Name: Anonymous 2008-04-14 8:05

>>10
fuck. now you know why it's not a good idea to write code when you're drunk

Name: Anonymous 2008-04-14 8:57

>>11
public static final NULL NULL NULL NULL NULL NULL NULL NULL
nyoro~n

Name: Anonymous 2008-04-14 8:58

>>11


Good try but I don't thing he's able to use Strings (at least he's receiving two final chars)

Name: Anonymous 2008-04-14 15:16

>>14
Good try but I don't thing he's able to use his head (at least he's writing his DNA program in Java)

Name: Anonymous 2009-03-06 10:44

here it is in   mind I have   no regrets this   was the only   resources someone would   consider them worth?

Name: Sgt.Kabukiman 2012-05-22 3:25

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List