|
User since: |
Oct 01, 2003 at 11:47 UTC
(21 years ago) |
Last here: |
Oct 14, 2024 at 08:56 UTC
(19 hours ago) |
Experience: |
21066
|
Level: | Abbot (19) |
Writeups: |
2802
|
Location: | Budapest |
User's localtime: |
Oct 15, 2024 at 05:27 CEST
|
Scratchpad: |
View
|
For this user: | Search nodes |
|
Image: colorful houses in Stortorget, Gamla stan, Stockholm, Sweden, 2014.
My homepage doesn't have anything interesting on it.
To determine if a number is odd or even, the worst way is:
$odd=0;{local($SIG{__WARN__},$^W)=(sub{$odd++})x2;+{1..abs($n)}};
There are several completely different programming concepts called a select statement. They are
-
The select system call in unix, which is the most common way a process can wait for events and give up the process's claim on CPU. Its prototype is int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);. It also has a perl interface: the select builtin function which has three or four arguments.
-
The one-argument select function of perl, which selects a filehandle to be the default filehandle, so that unqalified print operations and a few special variables would refer to it. This accidentally has the same name as the previously mentioned select function, and can only be distinguished by the number of arguments.
-
The select special command in bash-like shells, which is a loop construct that prints a simple text-based menu and reads user input.
-
The SELECT construct in the SQL language.
-
The SELECT special statement in newer dialects of BASIC, which is similar to pascal or scheme case statements. It dispatches between multiple choices comparing a single value to different constants for each branch. In earlier BASICs, the ON ... GOTO construct was used instead.
-
It is not a statement, but smalltalk and ruby have a select method which filter elements from a list, similarly to perl's builtin function grep. Also both maple and mathematica have functions called select and Select resp., and these serve the same purpose.
-
Also not a statement, but HTML has a select element that is a form control displaying a dropdown list. Related to this, the CGI perl module has a Select function and method, and the WWW::Mechanize module has a select method. (One could say though that this has the same etimology as the select statement in shells.)
-
However, HTML DOM also has a select event (unrelated to the select element) and HTML has a corresponding onselect attribute, which is called when the user changes the selection in a text input field.
-
The Magma computer algebra system has a select keyword which it uses in the conditional expression. The select function in Eigen is an elementwise conditional.
-
In the INTERCAL esoteric language, the ~ binary operator, called select, which does a compress operation on bits.
Ok, after all this rant, here's something that's actually useful to know. The formulae to solve the quadratic equation
a x^2 + b x + c = 0
are:
x_1 = -(b + sgn(b) sqrt(b^2 - 4 a c))/(2 a)
x_2 = c/(a x_1)
Perl Quiz of The Week #21 (20040805): Task scheduling. my solution discussion.
Perl Quiz of the Week Expert #22 (20040825): Word ladder. my solution discussion.
Favourite pentomino pattern:
|