Python function cis.read_data() equivalent in Julia

You could do:

"""
    read_data(read_function, data_list)
Wrapper for calling an HDF reading function for each dataset, and then concatenating the result.
 - data_list: A list of data objects to read
 - read_function: A function for reading the data, or 'SD' or 'VD' for default reading routines.
Return single array of concatenated data values.
"""
function read_data(read_function::Function, data_list)
    # note I change the order of args because it's more Julian this way
    return stack(read_function, data_list)
end

# if you really want that string argument as well you could define something like
function read_data(functionname::String, data_list)
    # now determine the function to call and just call 
    return read_data(myfun, data_list)
end
1 Like