1,499
reputation
3
15
35

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

How to get help in R


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").

Error handling example.

SLURM

Pass variables to SLURM: https://stackoverflow.com/questions/45592730

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

8
answers
15
questions
~176k
people reached
  • Member for 10 years, 10 months
  • 80 profile views
  • Last seen Aug 29 at 9:13

Top tags (44)

Score 22
Posts 6
Posts % 26
Score 2
Posts 2
Score 1
Posts 3
Score 1
Posts 2
Score 1
Posts 2
Score 1
Posts 2

Top posts (23)

View all questions and answers

Badges (53)

Gold

3

Rarest

Silver

15

Rarest

Bronze

35

Rarest