Questions tagged [built-in]

Built-in functions, modules and classes are standard parts of a programming language or framework.

Built-in functions, modules and classes are standard parts of a programming language or framework.

Generally, all parts of a programming language or framework that don't require the installation of additional components are considered built-in.

1177 questions
452
votes
12 answers

What is the purpose of the : (colon) GNU Bash builtin?

What is the purpose of a command that does nothing, being little more than a comment leader, but is actually a shell builtin in and of itself? It's slower than inserting a comment into your scripts by about 40% per call, which probably varies…
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
193
votes
7 answers

What is the advantage of GCC's __builtin_expect in if else statements?

I came across a #define in which they use __builtin_expect. The documentation says: Built-in Function: long __builtin_expect (long exp, long c) You may use __builtin_expect to provide the compiler with branch prediction information. In general,…
RajSanpui
  • 11,556
  • 32
  • 79
  • 146
142
votes
3 answers

Don't display pushd/popd stack across several bash scripts (quiet pushd/popd)

Each time I use pushd or popd, it print the stack to standard output. How not to do so? I don't want to do pushd > /dev/null each time because I have a lot of scripts calling each other. Maybe a nice override will do it, but I'll need to override…
bemug
  • 1,694
  • 2
  • 12
  • 10
119
votes
9 answers

Geometric Mean: is there a built-in?

I tried to find a built-in for geometric mean but couldn't. (Obviously a built-in isn't going to save me any time while working in the shell, nor do I suspect there's any difference in accuracy; for scripts I try to use built-ins as often as…
doug
  • 69,080
  • 24
  • 165
  • 199
113
votes
9 answers

Decorating Hex function to pad zeros

I wrote this simple function: def padded_hex(i, l): given_int = i given_len = l hex_result = hex(given_int)[2:] # remove '0x' from beginning of str num_hex_chars = len(hex_result) extra_zeros = '0' * (given_len - num_hex_chars)…
jon
  • 5,986
  • 5
  • 28
  • 35
102
votes
7 answers

Does Java have mutable types for Integer, Float, Double, Long?

I am in a situation where I want to use mutable versions of things like Integer. Do I have to use these classes (below) or does Java have something built in? http://www.java2s.com/Code/Java/Data-Type/Amutableintwrapper.htm
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
95
votes
11 answers

How can I read documentation about built in zsh commands?

It's frustrating when I do something like man bindkey and i get: BUILTIN(1) BSD General Commands Manual BUILTIN(1) NAME builtin, !, %, ., :, @, {, }, alias, alloc, bg, bind, bindkey, break, breaksw, builtins,…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
94
votes
1 answer

How to assign the result of the previous expression to a variable?

Suppose I'm using R's interactive console, and I've just done something like this: long_running_command() That long-running command returns a value, and I've just realized that I wanted to assign that value to a variable instead of discard it. So…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
93
votes
4 answers

What is the difference between a language construct and a "built-in" function in PHP?

I know that include, isset, require, print, echo, and some others are not functions but language constructs. Some of these language constructs need parentheses, others don't. require 'file.php'; isset($x); Some have a return value, others do…
Philippe Gerber
  • 17,457
  • 6
  • 45
  • 40
90
votes
7 answers

Exponentials in python: x**y vs math.pow(x, y)

Which one is more efficient using math.pow or the ** operator? When should I use one over the other? So far I know that x**y can return an int or a float if you use a decimal the function pow will return a float import math print( math.pow(10, 2)…
user3084006
  • 5,344
  • 11
  • 32
  • 41
80
votes
11 answers

How to find a value in an array and remove it by using PHP array functions?

How to find if a value exists in an array and then remove it? After removing I need the sequential index order. Are there any PHP built-in array functions for doing this?
DEVOPS
  • 18,190
  • 34
  • 95
  • 118
80
votes
7 answers

What does shift() do in Perl?

What could the following line possibly mean? my $x = shift;
cam
80
votes
4 answers

Why is 'dir()' named 'dir' in python?

In Python there is a built-in function called dir. This is used to get a list of all the attributes for an object. I understand what it does, but I am confused about why it is called dir. How is this name related to getting the attributes from an…
TM.
  • 108,298
  • 33
  • 122
  • 127
79
votes
9 answers

Performance of built-in types : char vs short vs int vs. float vs. double

Seeing Alexandre C's reply in the other topic, I'm curious to know that if there is any performance difference with the built-in types: char vs short vs int vs. float vs. double. Usually we don't consider such performance difference (if any) in…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
73
votes
9 answers

Extract file extension from file path

How can I extract the extension of a file given a file path as a character? I know I can do this via regular expression regexpr("\\.([[:alnum:]]+)$", x), but wondering if there's a built-in function to deal with this?
Suraj
  • 35,905
  • 47
  • 139
  • 250
1
2 3
78 79