Skip to main content
added 600 characters in body
Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 3939 30 bytes

((<&91*64&<)(32+#)`(I.@[,:32+])`]}])&.(a.i.])

Try it online!-9 thanks to xash

Convert the stringTry it online!

Uses Item Amend } to choose which characters need to be lowercased and which passed through unaltered.

It applies this operation "under" conversion to ascii indexes within the J alphabet &.(a.i.]) -- it first converts the string to the indexes of its characters, create a mask for those that are uppercasethan applies the item amend transformation, then converts back.

The item amend transformation is defined by the gerund (<&91*64&<)`(,:32+]). (,:32+]) defines the two possibilities: the input unaltered, then use amendor the the input shifted 32 places to the right, converting }A to update just those indexes I.a that are uppercase with their lowercase counterpart , etc. (32+#<&91*64&<) determines which integers go into which transformation category: If an integer is greater than 64 and less than 91 -- ie, the integers corresponding to ABCDEFGHIJKLMNOPQRSTUVWXYZ -- it gets shifted by 32.

J, 39 bytes

((<&91*64&<)(32+#)`(I.@[)`]}])&.(a.i.])

Try it online!

Convert the string to indexes within the J alphabet a., create a mask for those that are uppercase (<&91*64&<), then use amend } to update just those indexes I. that are uppercase with their lowercase counterpart (32+#)

J, 39 30 bytes

(<&91*64&<)`(,:32+])}&.(a.i.])

-9 thanks to xash

Try it online!

Uses Item Amend } to choose which characters need to be lowercased and which passed through unaltered.

It applies this operation "under" conversion to ascii indexes &.(a.i.]) -- it first converts the string to the indexes of its characters, than applies the item amend transformation, then converts back.

The item amend transformation is defined by the gerund (<&91*64&<)`(,:32+]). (,:32+]) defines the two possibilities: the input unaltered, or the the input shifted 32 places to the right, converting A to a, etc. (<&91*64&<) determines which integers go into which transformation category: If an integer is greater than 64 and less than 91 -- ie, the integers corresponding to ABCDEFGHIJKLMNOPQRSTUVWXYZ -- it gets shifted by 32.

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 39 bytes

((<&91*64&<)(32+#)`(I.@[)`]}])&.(a.i.])

Try it online!

Convert the string to indexes within the J alphabet a., create a mask for those that are uppercase (<&91*64&<), then use amend } to update just those indexes I. that are uppercase with their lowercase counterpart (32+#)