Stack Exchange network consists of 180 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn moreI use bash, R, Python, Raku, Perl, Java, and anything else that is needed.
Utilizo bash, R, Python, Raku, Perl, Java, o lo que sea necesario.
A good explanation of creating good reproducible R questions
#!/bin/env python
import argparse
parser = argparse.ArgumentParser(description='Determine the lines in common between two files')
parser.add_argument('fileA', help='file name')
parser.add_argument('fileB', help='file name')
args = parser.parse_args()
with open(args.fileA) as x: linesA = x.readlines()
with open(args.fileB) as x: linesB = x.readlines()
intersection = set(linesA).intersection(set(linesB))
print("".join(sorted(intersection)))
Usage message resulting from python intersection_of_lines.py --help
:
usage: intersection_of_lines.py [-h] fileA fileB
Determine the lines in common between two files
positional arguments:
fileA file name
fileB file name
optional arguments:
-h, --help show this help message and exit
#!/bin/env raku
sub MAIN #= Determine the lines in common between two files
( $fileA, #= file name
$fileB, #= file name
)
{
my @linesA = $fileA.IO.lines;
my @linesB = $fileB.IO.lines;
my $intersection = @linesA ∩ @linesB;
put $intersection.keys.sort.join("\n");
}
Yes that is ∩
, a real Unicode intersection symbol. The ASCII version (&)
also works.
You also get a nice usage message resulting from raku intersection_of_lines.raku --help
:
Usage:
./intersection_of_lines.raku <fileA> <fileB> -- Determine the lines in common between two files
<fileA> file name
<fileB> file name
Raku is a very clean, concise, understandable language. Its design pulls from the strengths of other languages.
Raku's rotor
(the "king of list manipulation").
Pass variables to SLURM: https://stackoverflow.com/questions/45592730
sbatch --export=GREETING=Hello,PLACE=world --wrap='echo "$GREETING $PLACE" > howdy.txt'
jupyter-nbconvert --to python notebook.ipynb --stdout --TemplateExporter.exclude_input_prompt=True
Why adjusted P-values are so important: https://www.xkcd.com/882
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.