1 sdump('D_FUNCTIONAL',"Loading functional.js\n");
3 function filter_list(list,f) {
7 if (t) new_list.push( list[i] );
12 function filter_object(obj,f) {
15 var t = f( i, obj[i] );
16 if (t) new_obj[i] = obj[i];
21 function find_list(list,f) {
24 if (t) return list[i];
29 function find_object(obj,f) {
31 var t = f( i, obj[i] );
37 function map_list(list,f) {
40 new_list.push( f( list[i] ) );
45 function map_flat_list(list,f) {
48 new_list = new_list.concat( f( list[i] );
53 function map_object(obj,f) {
56 new_obj[ f( i, obj[i] )[0] ] = f( i, obj[i] )[1];
61 function map_object_to_list(obj,f) {
64 new_list.push( f( obj, i ) );
69 function convert_object_list_to_hash(list) {
70 var my_hash = new Object();
72 for (var i = 0; i < list.length; i++) {
73 my_hash[ list[i].id() ] = list[i];
79 function find_id_object_in_list(list,id) {
80 //sdump('D_FUNCTIONAL','find_id_object_in_list(' + js2JSON(list).substr(0,20) + '... ,' + id + ')\n');
82 for (var i = 0; i < list.length; i++ ) {
84 if ( list[i].id() == id ) {
88 sdump('D_FUNCTIONAL','find_id_object_in_list error, i = ' + i + ' typeof(list[i]) = ' + typeof(list[i]) + ' list[i] = ' + js2JSON(list[i]) + ' : ' + js2JSON(E) + '\n');
92 //sdump('D_FUNCTIONAL','not found\n');
96 function find_attr_object_in_list(list,attr,value) {
98 for (var i = 0; i < list.length; i++ ) {
99 sdump('D_FUNCTIONAL','find_attr_object_in_list: i = ' + i + ' id = ' + list[i].id() + '\n');
101 var command = 'list[' + i + '].'+attr+'() == ' + value;
102 if ( eval(command) ) {
106 sdump('D_FUNCTIONAL','find_attr_object_in_list error, i = ' + i + ' typeof(list[i]) = ' + typeof(list[i]) + ' list[i] = ' + js2JSON(list[i]) + ' : list = ' + js2JSON(list) + ' : ' + js2JSON(E) + '\n');