Around 2010, especially since the Alice Decision in 2014, obtaining a patent for a process or function within software was extremely difficult. In fact during this time, 93% of software patents challenged were rejected.
This last June of 2018, a landmark ruling form the Federal Circuit Appeals Court resulted in the USPTO Berkheimer Memorandum that favors software innovation. It may take some time for patent examiners and the Patent Trial Appeals Board to catch up, but the future is bright for obtaining patents on novel innovations that run within software!