An optically driven digital metasurface for programming electromagnetic functions