Skip to main content
added 313 characters in body
Source Link
Downgoat
  • 29.1k
  • 6
  • 84
  • 155

Cheddar, 118 104 bytes

(s)->s.chars.map((i)->{if String.letters has i.lower{if i<"a"{i+i.lower}else{i+i.upper}}else{i}}).join()

First real Cheddar answer!!! This is a lot less climactic than I thought it would be... ;_;

Works with release 1.0.0-beta.9, non-competing.


As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            if i < "a" { // Check char code, meaning it's upper case if true
                i+i.lower
            }
            else {
                i+i.upper
            }
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");

Update: 7/14/16 I've finished ternaries making this come down to 84 bytes

Cheddar, 84 bytes

(s)->s.chars.map((i)->String.letters has i.lower?i<"a"?i+i.lower:i+i.upper:i).join()

works as of version v1.0.0-beta.14

Cheddar, 118 104 bytes

(s)->s.chars.map((i)->{if String.letters has i.lower{if i<"a"{i+i.lower}else{i+i.upper}}else{i}}).join()

First real Cheddar answer!!! This is a lot less climactic than I thought it would be... ;_;

Works with release 1.0.0-beta.9, non-competing.


As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            if i < "a" { // Check char code, meaning it's upper case if true
                i+i.lower
            }
            else {
                i+i.upper
            }
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");

Cheddar, 118 104 bytes

(s)->s.chars.map((i)->{if String.letters has i.lower{if i<"a"{i+i.lower}else{i+i.upper}}else{i}}).join()

First real Cheddar answer!!! This is a lot less climactic than I thought it would be... ;_;

Works with release 1.0.0-beta.9, non-competing.


As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            if i < "a" { // Check char code, meaning it's upper case if true
                i+i.lower
            }
            else {
                i+i.upper
            }
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");

Update: 7/14/16 I've finished ternaries making this come down to 84 bytes

Cheddar, 84 bytes

(s)->s.chars.map((i)->String.letters has i.lower?i<"a"?i+i.lower:i+i.upper:i).join()

works as of version v1.0.0-beta.14

added 199 characters in body
Source Link
Downgoat
  • 29.1k
  • 6
  • 84
  • 155

Cheddar, 118118 104 bytes

(s)->s.chars.map((i)->{if String.letters has i{i+i.upper}else lower{if String.letters has ii<"a"{i+i.lower}else{i+i.lowerupper}}else{i}}).join()

First real Cheddar answer!!! This is a lot less climactic than I thought it would be... ;_;

Works with release 1.0.0-beta.9, non-competing.


As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            i+i.if i < "a" { // Check char code, meaning it's upper case if true
        } else if String.letters has i   i+i.lower
            }
            else {
                i+i.lowerupper
            }
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");

Cheddar, 118 bytes

(s)->s.chars.map((i)->{if String.letters has i{i+i.upper}else if String.letters has i.lower{i+i.lower}else{i}}).join()

As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            i+i.upper
        } else if String.letters has i.lower {
            i+i.lower
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");

Cheddar, 118 104 bytes

(s)->s.chars.map((i)->{if String.letters has i.lower{if i<"a"{i+i.lower}else{i+i.upper}}else{i}}).join()

First real Cheddar answer!!! This is a lot less climactic than I thought it would be... ;_;

Works with release 1.0.0-beta.9, non-competing.


As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            if i < "a" { // Check char code, meaning it's upper case if true
                i+i.lower
            }
            else {
                i+i.upper
            }
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");
Source Link
Downgoat
  • 29.1k
  • 6
  • 84
  • 155

Cheddar, 118 bytes

(s)->s.chars.map((i)->{if String.letters has i{i+i.upper}else if String.letters has i.lower{i+i.lower}else{i}}).join()

As you can tell I didn't design cheddar to be golfy :/

Ungolfed:

(str) -> str.chars.map(
    (i) -> {
        if String.letters has i {
            i+i.upper
        } else if String.letters has i.lower {
            i+i.lower
        } else {
            i
        }
    }
).join()

Usage:

var doThing = <code here>;
doThing("input...");