GitHub Package
the javascript
16 - Arrays with One Type
func1 = (string_array) => string_array                  // array of strings
PRE_check_func1 = (string_array) => { 
  return type_czech.checkParam_type(string_array, ['strings'])
}
func1 = type_czech.linkUp(func1, PRE_check_func1)
func1(['pass', 'a-string'])                                    // pass
func1(['fail', 12])                                            // fail - 12
func2 = (string_array_2) => string_array_2            // array of 2 strings
PRE_check_func2 = (string_array_2) => { 
  type_signature = ['string', 'string']
  return type_czech.checkParam_type(string_array_2, type_signature)
}
func2 = type_czech.linkUp(func2, PRE_check_func2)
func2([ 'pass', 'two'])                                // pass
func2([ 'fail', 'two', 'three'])                       // fail - 3 elements
func3 = (arr_of_arr) => arr_of_arr                      // arrays of arrays
PRE_check_func3 = (arr_of_arr) => {
  return type_czech.checkParam_type(arr_of_arr, ['arrays'])
}
func3 = type_czech.linkUp(func3, PRE_check_func3)
func3([  [],  ['a'], [2], ['pass', 3]  ])               // pass
func3([  [],  [], [], 'fail'  ])                        // fail - not array
func4 = (arr_str_num_arrs) => arr_str_num_arrs          //[str, num] arrays
PRE_check_func4 = (arr_str_num_arrs) => {    
  the_signature = [ ['string', 'number'],  ['string', 'number'] ]
  return type_czech.checkParam_type(arr_str_num_arrs, the_signature)
}
func4 = type_czech.linkUp(func4, PRE_check_func4) 
func4([  ['a', 1], ['pass', 4]  ])                              // pass
func4([  ['a', 1], ['fail', 'X']  ])                            // fail - X
Contents 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    101 102 103 201 202 203 204 301 302 303 304 401 402 403 404 501 502 503 504 601 602 603 604    700 701 702 703 704 705 706 707 708 709 710 © 2024 Steen Hansen
Console Output