Here’s a demo of first-class functions in Morel. The “emps2” function (which is like a view or CTE in SQL) defines a column, “sum_dept_sal” whose value is a function that takes a department number and returns a total. The outer query calls that function by applying it to “e.deptno”.
The demo starts from scratch, so you can do the same if you have Git and a JDK installed.