a fold-map function for gel