The kitten command

65

4

A kitten is much like a cat. Some of the main differences are cuteness, lack of intelligence, and size. Similarly, the cat command is different from the kitten command. Fortunately, there is only one difference in this case. In the kitten command, all uppercase letters are replaced with lowercase letters.


Objective

To implement a program that behaves similarly to cat. All characters [A-Z] are outputted lowercase.


Input

A list of files as command line arguments. If no files are listed, then read from standard input. The input may contain unprintable characters and characters outside the ASCII range.


Output

If input is a bunch of files, concatenate the contents and output all characters as lowercase. If reading from STDIN, output the contents of STDIN with all uppercase letters as lowercase.

Note: Only make the characters [A-Z] lowercase. It is unacceptable if any other characters are made lowercase.


Examples

$ echo "HelLo" > file.txt
$ kitten file.txt
hello
$ echo "Good Bye" | kitten
good bye
$ echo "Ä" | kitten
Ä

As usual with , least bytes wins.

Leaderboards


Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=59029,OVERRIDE_USER=32700;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

TheNumberOne

Posted 2015-09-29T16:50:26.303

Reputation: 10 855

2By explicitly stating "Only make the characters [A-Z] lowercase" are you anticipating Unicode input? – AdmBorkBork – 2015-09-29T16:55:47.470

2@TimmyD Yes, but it is mainly to prevent people from using built in to lowercase functions. – TheNumberOne – 2015-09-29T16:58:09.127

Could you give an example where those built in functions might fail? – FryAmTheEggman – 2015-09-29T17:05:48.420

3

@FryAmTheEggman permalink

– Dennis – 2015-09-29T17:06:41.693

1How about Ü, Ñ and the likes? – Mast – 2015-10-01T01:02:50.513

2It's so nice when you don't see any Pyth at all in a codegolf... – jmm – 2015-10-04T18:11:21.003

Answers

52

Perl, 6 bytes

5 bytes code + 1 byte command line

$_=lc

Example usage:

echo ABCdef | perl -p kitten.pl
abcdef

Confirmation of correct Unicode behaviour:

echo "HelloÉ" | perl -p kitten.pl
helloÉ

steve

Posted 2015-09-29T16:50:26.303

Reputation: 2 276

2Are you sure this doesn't affect Unicode characters? – Martin Ender – 2015-09-30T08:03:33.400

7

@MartinBüttner It does not. We're in the “otherwise” category here: “ASCII rules are used for the case change. The lowercase of any character outside the ASCII range is the character itself.” My +1 for the answer.

– xebtl – 2015-09-30T12:59:55.080

178

Bash, 19 bytes

cat "$@"|tr A-Z a-z

The best way to make kittens is to use actual cats.

Example run

$ ./kitten kitten
cat "$@"|tr a-z a-z

Dennis

Posted 2015-09-29T16:50:26.303

Reputation: 196 637

39The right tool for the job. – Digital Trauma – 2015-09-29T17:24:33.357

120+1 for only needing one cat to make a kitten, always takes me two cats – SnoringFrog – 2015-09-29T23:00:50.253

4Now that reminds me of those man woman jokes … – xebtl – 2015-09-30T13:01:52.027

2+1 for going for the cat cloning rather than mating method of creating offspring – MD-Tech – 2015-09-30T15:45:16.347

25@SnoringFrog He bashed the other one. – TheNumberOne – 2015-09-30T19:46:00.163

2This is probably the only one that's truly correct, as each other solution ignores, say, cat a.txt - b.txt (insert stdin between the contents of the two files) and cat -s file.txt (a flag to replace repeated newlines with at most two). – CR Drost – 2015-10-01T14:34:17.933

22

Perl, 11 bytes

10 bytes code + 1 byte command line

y/A-Z/a-z/

Example usage:

perl -p entry.pl input1.txt input2.txt
echo "ABCdef" | perl -p entry.pl

Jarmex

Posted 2015-09-29T16:50:26.303

Reputation: 2 045

15

Python 3, 77 bytes

from fileinput import*
print(end=b''.join(input(mode='rb')).lower().decode())

Anders Kaseorg

Posted 2015-09-29T16:50:26.303

Reputation: 29 242

1That's clever, using bytes to avoid non-ASCII from changing. – matsjoyce – 2015-09-30T07:29:10.370

11

Ruby, 13 bytes

The byte count includes 1 byte for the p flag. Run it like so: ruby -p kitten.rb.

$_.downcase!

Takes input from stdin or file arguments, just like grown up cat.

daniero

Posted 2015-09-29T16:50:26.303

Reputation: 17 193

Does this only downcase ASCII, or also other characters like Ä? – Paŭlo Ebermann – 2015-09-30T07:58:19.170

1@PaŭloEbermann: I just tested it: echo "HelloÉ" | ruby -p kitten.rb -> helloÉ – Neil Slater – 2015-09-30T08:25:12.190

I swear there was a whole bunch of comments here regarding that yesterday. I don't know where those went, but: Yes, it works according to the spec. – daniero – 2015-09-30T10:29:10.917

5

PowerShell, 112 Bytes

function l([string]$a){97..122|%{[char]$b=$_;$a=$a-split$b-join$b};$a}if($args){$args|%{l(gc $_)}}else{l $input}

Horrendously unreadable. Here's a slightly expanded version below:

function l([string]$a){
  97..122|%{
    [char]$b=$_
    $a=$a-split$b-join$b
  }
  $a
}

if($args){
  $args|%{
    l(gc $_)
  }
}
else{
  l $input
}

Defines an internal function l which iterates over a loop from 97 to 112 (i.e., ASCII a to ASCII z). Splits the input string over that character (yay case-insensitive default), the rejoins it with the "correct" lower case. Do note that yes, this means "Test" would briefly become "T st" as it's iterating through the e, for example. Doesn't affect output.

The second half is the tricky bit to figure out if we have pipeline input (equivalent to stdin for PowerShell) or command-line input. The special variable $args is only present if command-line input is present, so we loop over each one, gc (for Get-Content) and schlep that up to l. Otherwise, we just schlep our $input up to l. Note that we could swap our if/else statements (i.e., if($input)), but since "input" is one character longer than "args" this way is shorter.

AdmBorkBork

Posted 2015-09-29T16:50:26.303

Reputation: 41 581

@Nazek The built-in "String".ToLower() would also lowercase Unicode characters, which is against the rules. There's a lot of stuff that PowerShell doesn't do right with regards to Unicode, but unfortunately this is one instance that it works correctly. – AdmBorkBork – 2015-09-30T02:39:25.590

5

Python 2, 53 bytes

from fileinput import*
print''.join(input()).lower(),

Anders Kaseorg

Posted 2015-09-29T16:50:26.303

Reputation: 29 242

5

R, 97 bytes

cat(chartr("A-Z","a-z",sapply(if(length(a<-commandArgs(T))){a}else{"stdin"},readLines)),sep="\n")

Usage:

$ echo "HeLlo" > file.txt
$ Rscript kitten.R file.txt
hello
$ echo "Good Bye" | Rscript kitten.R
good bye
$ echo "bLABLa" > file2.txt
$ Rscript kitten.R file.txt file2.txt
hello
blabla
$ echo Ä | Rscript kitten.R
Ä

plannapus

Posted 2015-09-29T16:50:26.303

Reputation: 8 610

5

CoffeeScript, 292 bytes

f=require 'fs';d='';p=process;v=p.argv;s=p.stdin;l=((d)=>console.log d.replace /([A-Z])/g,(a,l)=>l.toLowerCase());if v.length>2 then(v.forEach (v,i)=>if i>1 then(f.exists v, (e) =>if e then(f.readFile v,'utf-8',(r,d)=>l d) else l v))else(s.resume();(s.on 'data',(c)=>d+=c);s.on 'end',()=>l d)

Usage:

$ echo "HelLo" > file.txt
$ coffee kitten.coffee file.txt
hello
$ echo "Good Bye" | coffee kitten.coffee
good bye
$ echo "Ä" | kitten
Ä
$ coffee kitten.coffee file.txt SoMeTeXt
sometext
hello

My first participation on codegolf so please don't be rude :).

For sure this code can be golfed more and coffee/javascript isn't the best choice to do that, but it does what's expected.

When it reads arguments it also takes care about file existency (if file does not exists, the string is kittened.)

Any help or advice to improve this code is welcome !

dunpeal69

Posted 2015-09-29T16:50:26.303

Reputation: 51

4

Julia, 123 bytes

f(s)=for l=readlines(s) print(replace(l,r"[A-Z]",lowercase))end
A=ARGS
length(A)>0?for i=A open(f,i)end:open(f,readline())

Ungolfed:

function file_to_lower(s::Stream)
    # Loop over the lines of the input stream
    for l in readlines(r)
        # Print the lowercased line
        print(replace(l, r"[A-Z]", lowercase))
    end
end

if length(ARGS) > 0
    # Loop over the files specified from the command line
    for i in ARGS
        # Open the file, apply the function, then close it
        open(file_to_lower, i)
    end
else
    # Get the input file from STDIN
    open(file_to_lower, readline())
end

Alex A.

Posted 2015-09-29T16:50:26.303

Reputation: 23 761

4

Python 2, 100 102 97 bytes

Functionality corrected (and 4 bytes added) by matsjoyce. Fortunately, I saved two bytes by switching to Python 2.

from sys import*;print''.join(f.read().lower()for f in(map(open,argv[1:])if argv[1:]else[stdin]))

Takes arguments from the command line, or from STDIN if no arguments found.

This abuses the default arguments of some functions. By default, open uses read-only text mode, which is exactly what we want. read, if called with no arguments, will return all text in the stream.

Ungolfed:

import sys

if len(sys.argv) > 1:              # If we have command-line arguments:
    source = []                    # Initialize an empty list
    for path in sys.argv[1:]:      # Iterate through every filename we have
        kitfile = open(path, 'rt') # Open the file in read-only text mode
        source.append(kitfile)     # Add it to the list
else:                              # Otherwise, if the args are empty:
    source = [sys.stdin]           # Set our source to STDIN wrapped in a list

kittened = []                      # Initialize an empty list
for kitfile in source:             # Iterate through every file (or just STDIN)
    text = kitfile.read()          # Read everything from the stream
    kitten_text = text.lower()     # Make it lowercase
    kittened.append(kitten_text)   # Add it to the list
final = ''.join(kittened)          # Join everything together
print final                        # Print the result

jqblz

Posted 2015-09-29T16:50:26.303

Reputation: 2 062

1This won't work for stdin, as you only read one line, and do not lowercase it. – matsjoyce – 2015-09-29T19:43:04.167

@matsjoyce I've fixed my code. Thanks for the reminder! Unfortunately, it added four bytes, but by no longer depending on input not evaluating, I could switch to Python 2 and remove the parentheses on print. – jqblz – 2015-09-29T22:34:52.320

4

CJam, 18 bytes

ea_:gs{q}?'_,_eler

The list of files must be supplied in form of URLs, which is the only format CJam understands.

Example runs

$ cjam kitten <<< "AaÁáÄä"
aaÁáÄä
$ cjam kitten file:///home/dennis/kitten file:///home/dennis/kitten
ea_:gs{q}?'_,_elerea_:gs{q}?'_,_eler

How it works

ea                  Push the array of command-line arguments.
  _                 Push a copy.
   :g               Retrieve the contents of all files with those URLS.
     s              Flatten the resulting array of strings.
      {q}           Push a block that reads all input from STDIN.
         ?          Select the string of the array of args is non-empty.
                    Otherwise, execute the code block.
          '_,       Push the string of all ASCII characters before _.
             _el    Push a copy and convert it to lowercase.
                er  Perform transliteration.

Dennis

Posted 2015-09-29T16:50:26.303

Reputation: 196 637

3

Python 3, 124 123 bytes


from sys import*
for f in list(map(open,argv[1:]))or[stdin]:print(f.read().translate({i:i+32for i in range(65,91)}),end="")

Python eats kittens!

$ python kitten.py file.txt
hello
$ echo "Good Bye" | python kitten.py 
good bye
$ echo "Ä" | python kitten.py 
Ä

matsjoyce

Posted 2015-09-29T16:50:26.303

Reputation: 1 319

3

C, 106 108 bytes

Edit: Fixed a mistake that creeped in when squeezing bytes. Stdin wasn't working, now it is.

I'm pretty sure I could squeeze some bytes away, but here's an easy-to-grasp, not at all language abusive, submission:

main(n,s,f,c)void**s;{for(f=n-1?open(*++s,0,0):0;read(f,&c,1);putchar(64<c&c<91?c+32:c));n-->2&&main(n,s);}

And a somewhat more neatly formatted version for reading:

main(n,s,f,c)
void**s;
{
    for(f=n-1?open(*++s,0,0):0; read(f,&c,1); putchar(64<c&c<91?c+32:c));
    n-->2&&main(n,s);
}

algmyr

Posted 2015-09-29T16:50:26.303

Reputation: 858

+1 because this taught me that implicit int parameters are only possible with K&R syntax. – Felix Dombek – 2015-10-01T22:50:38.397

2

Haskell, 133

import System.Environment
main=getArgs>>=mapM_(>>=putStr.map l).f
f[]=[getContents]
f n=map readFile n
l x=[x..]!!sum[32|x>'@',x<'[']

The cat-style args processing is derived from this tutorial, then rearranged to shave characters.

Explaining l, the function to lowercase one character:

  • sum[32|condition] is a shorter form of if condition then 32 else 0.
  • [x..]!!count is iterate succ x !! count is toEnum $ fromEnum x + count and shorter than importing and using Data.Char.toLower with a condition to restrict it to ASCII.
  • '@' and '[' are the characters immediately preceding A and following Z, so that I can use < instead of <=.

Thanks to Anders Kaseorg for contributing the sum[...|...] and [x..]!! tricks.

Kevin Reid

Posted 2015-09-29T16:50:26.303

Reputation: 1 693

1l x=[x..]!!sum[32|x>'@',x<'['] – Anders Kaseorg – 2016-02-26T23:41:29.657

2

Mathematica, 66 bytes

kit=StringReplace[#,x:RegularExpression["[A-Z]"]:>ToLowerCase[x]]&

Called as

kit@"HelLo"

Mathematica already has a ToLowerCase function, but it converts special (Unicode and mathematical) characters as well. So I had to kittenize it. This function will take any input.

Verbeia

Posted 2015-09-29T16:50:26.303

Reputation: 131

@TheNumberOne - that is how it works in Mathematica. No more code is needed to do this. If you want an executable, then Mathematica isn't the tool. – Verbeia – 2015-10-01T23:39:22.887

Does this concatenate files whose names are input as command-line arguments, as required? – msh210 – 2016-03-06T06:19:42.223

Command-line args don't exist in Mathematica. It conkittenates its function inputs. Also you don't need to assign to a variable. – CalculatorFeline – 2016-03-07T00:51:43.867

2

C#, 230 226 bytes

namespace System{using Linq;class P{static void Main(string[]a){Console.Write(string.Concat((a.Length>0?string.Concat(a.Select(f=>IO.File.ReadAllText(f))):Console.In.ReadToEnd()).Select(c=>c>'@'&&c<'['?char.ToLower(c):c)));}}}

Ungolfed:

namespace System
{
    using Linq;
    class P
    {
        static void Main(string[] a)
        {
            Console.Write(                                                  // Print...
                string.Concat(                                                  // ...all chars combined to a string...
                    (a.Length > 0 ?                                             // ...commandline arguments?...
                        string.Concat(a.Select(f => IO.File.ReadAllText(f))) :  // ...then all files as single string...
                        Console.In.ReadToEnd()                                  // ...else STDIN input
                    ).Select(c => c > '@' && c < '[' ? char.ToLower(c) : c)     // ...Lowercase only A..Z
                )
            );  
        }
    }
}

RobIII

Posted 2015-09-29T16:50:26.303

Reputation: 397

1

C#, 342 bytes

  • takes file list from passed arguments.
  • read every char in every file than only converts to lower case if and only if the character in the A..Z range than send it to STDOUT.
  • If there is no file list than reads STDIN, reads every char, converts to lower case if and only if the character in the A..Z range than send it to STDOUT.
namespace System{
using IO;
using Linq;
class P{
static void Main(string[]a){
Action<char>e=C=>{var c=char.ToLower(C);Console.Out.Write(c>='a'&&c<='z'?c:C);};
if(a.Length>0)a.ToList().ForEach(f=>File.ReadAllText(f).ToCharArray().ToList().ForEach(e));
else 
while(true) Console.In.ReadLine().ToCharArray().ToList().ForEach(e);
}
}
}

C#, 319 bytes

single-liner, same as above:

namespace System{using IO;using Linq;class P{static void Main(string[]a){Action<char>e=C=>{var c=char.ToLower(C);Console.Out.Write(c>='a'&&c<='z'?c:C);};if(a.Length>0)a.ToList().ForEach(f=>File.ReadAllText(f).ToCharArray().ToList().ForEach(e));else while(true)Console.In.ReadLine().ToCharArray().ToList().ForEach(e);}}}

underscore

Posted 2015-09-29T16:50:26.303

Reputation: 119

1

S.I.L.O.S 179 characters

loadLine :
a = 256
x = get a
lbla
X = x
B = x
C = 91
B - 64
if B c
printChar x
GOTO x
lblc
C - x
if C D
printChar x
GOTO x
lblD
x + 32
printChar x
lblx
a + 1
x = get a
if x a
lblb

Feel free to try this code online!


Essentially it translates to this in pusedocode.
String input = input();
for(char c in input)
if(c is uppercase) print c + 32/*lowercase c*/else print c

Rohan Jhunjhunwala

Posted 2015-09-29T16:50:26.303

Reputation: 2 569

0

sed, 14 bytes

s/[A-Z]/\L\0/g

Run with env -i sed -f kitten.sed.

Ángel

Posted 2015-09-29T16:50:26.303

Reputation: 286

1Since this is just a fancy way for saying LANG=C sed -f kitten.sed, I'm unsure if I should apply a penalty to account for that. This question doesn't specify how to count program calls, and it doesn't seem addressed in meta. – Ángel – 2015-10-01T00:25:31.723

Does this concatenate files whose names are input as command-line arguments, as required? – msh210 – 2016-03-06T06:18:09.677

@msh210 Yes, of course. – Ángel – 2016-03-14T01:12:07.720

1@Ángel s/.*/\L&/ for a nine bytes solution – someonewithpc – 2016-07-24T14:52:43.460

Thanks @someonewithpc. Both s/.*/\L&/ and s/./\L&/g are indeed 9-byte solutions! – Ángel – 2016-07-24T19:50:00.680

0

C, 91 bytes

#include <stdio.h>
main(){int c;while(EOF!=(c=getc(stdin))){c=tolower(c);putc(c,stdout);}}

C, 98 bytes

#include <stdio.h>
main(){int c;while(EOF!=(c=getc(stdin))){if(c>64&&c<91)c+=32;putc(c,stdout);}}

Though if readability mattered more than byte count the same logic is written below:

#include <stdio.h>
main()
{
int c;
        while (EOF != (c = getc(stdin))) {
                if ((c >= 'A') && ((c <= 'Z')))
                        c = (c - 'A') + 'a';
                putc(c,stdout);
        }
}

Dave Thompson

Posted 2015-09-29T16:50:26.303

Reputation: 1

This fails the first test case. – TheNumberOne – 2015-10-01T23:26:28.300

This does not fulfill the spec. It should behave like cat in the sense that you take filenames as arguments and if no filenames are given, read from stdin. You currently read only from stdin. – algmyr – 2016-07-25T00:57:36.437

0

Java, 198 bytes

b->B->{B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;};

You are forced to use the above lambda with files, so there's no need to take input from STDIN! Also, it's a Function<File[], UnaryOperator<String>>. It's used like foo.apply(anArrayOfFiles).apply(anything).

As something that makes more sense to those who are new to Java, it takes 223 bytes:

String A(java.io.File[]b){String B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;}

As something that compiles, it takes up 232 bytes:

class a{String A(java.io.File[]b){String B="";for(java.io.File c:b)B+=new java.util.Scanner(c).useDelimiter("\\Z").next();for(int c=0;c++<B.length;)if(B.charAt(c)>64&B.charAt(c)<91)B=B.replace(B.charAt(c),B.charAt(c)|32);return B;}}

user8397947

Posted 2015-09-29T16:50:26.303

Reputation: 1 242