time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (1975B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Argument Function
     22 
     23 > Create an argument function.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var argumentFunction = require( '@stdlib/utils/argument-function' );
     37 ```
     38 
     39 #### argumentFunction( idx )
     40 
     41 Returns a `function` which always returns an argument corresponding to a specified argument index.
     42 
     43 ```javascript
     44 var argn = argumentFunction( 1 );
     45 // returns <Function>
     46 
     47 var v = argn( 1.0, 2.0, 3.0 );
     48 // returns 2.0
     49 
     50 v = argn( 'a', 'b', 'c' );
     51 // returns 'b'
     52 ```
     53 
     54 If an argument function is provided fewer arguments than the specified argument index, an argument function returns `undefined`.
     55 
     56 ```javascript
     57 var argn = argumentFunction( 100 );
     58 // returns <Function>
     59 
     60 var v = argn( 1.0 );
     61 // returns undefined
     62 ```
     63 
     64 </section>
     65 
     66 <!-- /.usage -->
     67 
     68 <section class="notes">
     69 
     70 ## Notes
     71 
     72 -   Argument indices are **zero-based**.
     73 
     74 </section>
     75 
     76 <!-- /.notes -->
     77 
     78 <section class="examples">
     79 
     80 ## Examples
     81 
     82 <!-- eslint no-undef: "error" -->
     83 
     84 ```javascript
     85 var randu = require( '@stdlib/random/base/randu' );
     86 var argumentFunction = require( '@stdlib/utils/argument-function' );
     87 
     88 var argn;
     89 var v;
     90 var i;
     91 
     92 argn = argumentFunction( 1 );
     93 for ( i = 0; i < 10; i++ ) {
     94     v = argn( randu(), randu()*10.0, randu()*100.0 );
     95     console.log( v );
     96 }
     97 ```
     98 
     99 </section>
    100 
    101 <!-- /.examples -->
    102 
    103 <section class="links">
    104 
    105 </section>
    106 
    107 <!-- /.links -->