Christopher Bottoms
I use Python, Raku, Perl, R, Java, bash, and anything else that is needed.
Utilizo Python, Raku, Perl, R, Java, bash, o lo que sea necesario.
A good explanation of creating good reproducible R questions
Python 3 vs Raku
Python 3: Unordered common lines between two files:
#!/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
Raku: Unordered common lines between two files:
#!/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 tidbits
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").
SLURM
Pass variables to SLURM: Passing SLURM batch command line arguments to R
sbatch --export=GREETING=Hello,PLACE=world --wrap='echo "$GREETING $PLACE" > howdy.txt'
convert Jupyter notebook (https://stackoverflow.com/a/50567584/215487)
jupyter-nbconvert --to python notebook.ipynb --stdout --TemplateExporter.exclude_input_prompt=True
Why adjusted P-values are so important: https://www.xkcd.com/882
-
Member for 11 years, 3 months
-
16 profile views
-
Last seen Feb 8 at 14:45
Communities (39)
- Stack Overflow 10.1k 10.1k 66 gold badges4444 silver badges8787 bronze badges
- Vi and Vim 3k 3k 33 gold badges1515 silver badges3333 bronze badges
- Super User 1.6k 1.6k 44 gold badges1616 silver badges3636 bronze badges
- Stack Overflow en español 845 845 66 silver badges1717 bronze badges
- Server Fault 287 287 22 silver badges1111 bronze badges
- View network profile
Top network posts
- 86 What's the simplest way to strip trailing whitespace from all lines in a file?
- 73 How can I yank (copy) the single character on which the cursor rests?
- 43 Converting rows into columns and columns into rows using R
- 41 How can I make my own "shell commands" (e.g. mkdir/cd combo)?
- 41 What is the difference between a list and a pairlist in R?
- 34 What does !! (double exclamation point) mean?
- 34 ¿Por qué mis programas no pueden hacer cálculos aritméticos correctamente?
- View more network posts →