151
reputation
4

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

0
answers
1
question
~116
people reached
  • Member for 9 years, 5 months
  • 1 profile view
  • Last seen Nov 19 '19 at 21:02

Top tags (1)

Score 0
Posts 1
Posts % 100

Top posts (1)

Badges (4)

Gold

Silver

Bronze

4

Rarest