Retorna una funcion en lua para convertir colores rgb a colores oklch.
- User
Retorna una funcion en lua para convertir colores rgb a colores oklch.
- Assistant
- User
Refactoriza el siguiente código para hacerlo más eficiente y fácil de entender
--- Search for the file "*.css" in the current directory and parent directories. M.find_file = function(fname, dir, attempt, limit) local escape_shell_arg = function(arg) return "'" .. arg:gsub("'", "'\\''") .. "'" end if not attempt or attempt > limit then return false end dir = dir or "" local escaped_dir = escape_shell_arg(dir) local handle = io.popen("ls -1 " .. escaped_dir .. " 2>/dev/null") if not handle then return false end local isAttemptOne = (attempt == 1) for file in handle:lines() do if file == fname then handle:close() return dir .. (isAttemptOne and fname or "/" .. fname) end end handle:close() dir = dir .. "../" return M.find_file(fname, dir, attempt + 1, limit) end --- Open a file and return its contents M.open_file = function(fpath) local file = io.open(fpath, "r") if not file then return end local contents = {} for line in file:lines() do table.insert(contents, line) end file:close() return contents end - Assistant
- User
Puedes mejorar el codigo anterior?
- Assistant