Uniligne

A uniligne is generally a computer program disposable, but not very banal, writing for a specific task in a Langage of script such as Perl or Ruby, and holding on only one line. Languages which impose several phases before the execution, the explicit declaration of Variable S, function S or, worse, of class S, do not lend themselves to the unilignes. The unilignes typically exploit qualities DWIM of a language.

Because a uniligne is seldom intended to be re-used, the considerations of legibility by a third are secondary. Some unilignes are deliberated darkenings.

History

The word appeared for the first time in the book of Alfred V. Aho, Peter J. Weinberger and Brian W. Kernighan, The AWK Programming Language . This book has as a subject the language Awk, used in the operating system Unix. The authors explain how their daily work on Unix was at the origin of this paradigm:

Examples

In AWK

The book The AWK Programming Language contains more than twenty examples at the end of the first chapter.

Here first:

1. To post the full number of lines read in entry:
END {print NR}
2. To post to it tenth line of a file:
NR == 10
3. To post the last field of each line:
{print $NF}

In Perl

To reverse all the bytes of a file (in Perl):

Perl -0777e “print scalar reverse <>” nomFichier

The unilignes are also used to show the expressivity of certain computer programming languages. They are often used to show the talent of the programmer, and of many contests are organized to know who will make most exceptional.

In C

Here an example out of C, prize winner of the contest IOCCC.

hand (int C, tank ** v) {return! m (v, v);}m (char*s, char*t) {return*t-42? *s? 63==*t|*s==*t&&m (s+1, t+1):! *t: m (S, t+1)||*s&&m (s+1, T);}

This program makes it possible to check if a character string corresponds to a pattern, with Unix conventions: * for a continuation of caratères unspecified unspecified length? for only one character… The code of return is 0 for truth and 1 if not. To note that the pattern matching is done on all the chain, and not on a subset of this one. Examples of execution:

$ prog foo “F?? ”; echo $? $ prog “unspecified chain” “?? ai*e ** N? *”; echo $? - > 1 returns $ prog “unspecified chain” “ch*o? ”; echo $? - > 0 return

In Haskell

There are two declarations import what changes actually the number of lines of the program to three. This uniligne sorts the lines which it takes in entry according to the collating Sequence of the code ASCII.

importation IO List importation hand = (sequence. map putStrLn. leaves. lines) =<< getContents

In Java

Hello world in Java: public class public OneLine {static void hand (String args) {System.out.println (" One-liner."); }}

See too

External bonds

  • Unilignes Perl
  • Perl One Liners
  • Perl Oneliners
  • Hot Perl OnLiners
  • Perl One Liners

Random links:ISO 3166-2: Al | Regional scientific advice of the natural heritage | Medal Julian C. Smith | The Range of Seville | Skobalj (Smederevo) | Sous-continent