4 ms·
Learning to Program Without Writing the Usual Sort of Code
- shakna 10y ago(define 2nd-largest (lambda args (let ((2large (car (car (sort-list args))))) 2large))) What does functional languages struggle with there? Lack of mutation makes that neither harder nor easier. I do understand that newcomers struggle with logic. That's clear. But a function is just something that takes input and produces output. There is no need to try to say that the functional paradigm is ill-suited because it doesn't have primitives. car, cdr and cons are ancient primitives that have equivalents in most modern functional languages. Python is used by a school near me, and students still end up with similar results. def scnd_largest(*args): args = sort(args) args.pop() return args.pop() There is nothing inherently wrong with the paradigm. Students need to learn the logic of problem solving, and it isn't very far removed from the contrived Pythagoras problems they solve, and if older, a background in lambda calculus can do wonders in learning to express oneself. If functional is truly too hard to grasp, then maybe Prolog might make a good starting point.
- deleted 10y ago[deleted]