/* * Load the file KhPol_knots_data if it wasn't already loaded. */ global(KHPOL_KNOTS_DATA); /* * Check whether a file exists of not */ file_exists(filename) = extern(concat(["test -e ", filename, " && echo 1 || echo 0"])); /* * Load file2load or file2load.gz (whatever exists) or print loaded_msg if * it's already been done, depending on the value of loaded_var. */ load_data_file(file2load, loaded_var, loaded_msg) = { if (eval(loaded_var) == "Loaded", /* Nothing to worry about, print the message and relax */ print(loaded_msg); , /* Ok, it's our first time here. Try to load the file then */ if (file_exists(file2load), read(file2load); , if (file_exists(concat(file2load, ".gz")), extern(concat(["zcat ", file2load, ".gz"])); , error("Neither file ", file2load, " nor ", file2load, ".gz exist!"); ); ); eval(concat(loaded_var, " = \"Loaded\"")); ); } load_data_file("KhPol_knots_data", "KHPOL_KNOTS_DATA", \ "Khovanov polynomials for knots with up to 13 crossings already loaded!");