Admittedly, teachers sometimes seem to lose track of this and assign busywork exercises for no good reason.
Also, Prolog does not have a "standard library". What predicates are implemented varies greatly by implementation, and if you want to write portable code then you have to stick as closely as possible to the ISO standard.
danilafe•15h ago
That aside, I wonder if getting the reverse solution (sum(?, 10)) is better served by the straightforward or the tedious approach. I suspect both would work just the same, but I'd be curious if anyone knows otherwise.
7thaccount•15h ago
It's existence obviously means some professor didn't allow them to use the standard library and they tongue in cheek show how irritating that is.
I'm sure it's possible they made it up, but we had similar restrictions where I could use an Arduino for my engineering Senior Design Project in college, but no Arduino or module libraries - just our own C. We passed, but barely. It also was weird as it didn't match how normal people would solve the problem.
Jtsummers•14h ago
> Now this is starting to look like Professor of Programming Languages code!
A lot of tier 2/3 CS schools with programming language courses (a survey of multiple languages across various paradigms) teach Prolog this way (and I've seen some fantastically terrible examples of Lisp code coming out of those same courses). It's unfortunate because, at these schools, this is often the only formal course where students branch out of C/Java/C++/C#/Python/JS (and they may only get 2-3 of those over the rest of their courses). It leaves the students with a gross misunderstanding of the languages and dread when they see them again.
Blackthorn•13h ago
7thaccount•38m ago
seba_dos1•13h ago
If I can solve a problem by building from preexisting LEGO blocks then I'll probably do that, but it wouldn't be a valuable learning exercise. Students aren't being given problems in need of effective solution, these problems are tools to facilitate understanding.
What you described could be pointless if it made you work on reimplementing trivial stuff that you'd already mastered long time ago instead of focusing on actual problem. Writing your 100th hashmap implementation or yet another I2C driver isn't particularly valuable. Since you mentioned "barely passing", I don't think that was the case though.
7thaccount•9h ago
yuye•24m ago
When I started compsci, it was the first year of a all-new curriculum for CompSci.
Literally the first week: We had to program an Arduino to play a song on a speaker by toggling GPIO, within a week. No assembly or any of that high-level mumbo-jumbo. We had to read the datasheet, look at the instructions and write the hex representation for each instruction in a txt file.
We had a "linker" tool: It took a basic bootloader (containing some helper functions for GPIO), turned our hex-txt file into actual binary, then just copies that to a set address. The bootloader did nothing more than init the GPIO pins and jump into our code.
We were given the locations of where these helper functions lived, nothing else.
It was to give a quick and intimate understanding of how CPUs actually work and why we use compilers and stuff. It worked really well, but it was so much of a pain that they changed it to allow students to use asm a year or two after.
floxy•14h ago
Doing an "all modes" predicate:
...where... ...is "True" as expected would probably be a pretty interesting exercise if you wanted to be able to get all of the lists. You'd probably need to do an "enumerate the rationals" type of thing, since you need to go to infinity in a couple of different directions at the same time. That is, you can't do nested loops/recursing: i.e. ...with an all-modes "add/3". Since there are an infinite supply of pairs that add up to, say 10: ...and you can also go to arbitrary list lengths: ...your life probably gets easier if you limit the domain to positive integers (without zero) since then the list length doesn't diverge. Then a declarative looking solution probably just has a all-modes equivalent to "sort" somewhere within? Certainly interesting to think about.https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/r...
https://prolog-lang.org/ImplementersForum/0103-modes.html
https://www.swi-prolog.org/pldoc/man?predicate=permutation%2...
ebolyen•14h ago
Ideas like fold and map where _never_ mentioned in lisp (to exaggerate, every function had to have the recursive implementation with 5 state variables and then a simpler form for the initial call), at no point did higher-order functions or closures make an appearance while rotating a list by 1 and then 2 positions.
The treatment of Prolog was somehow worse. Often the code only made any sense once you reversed what the lecturer was saying, realizing the arrow meant "X given Y" not "X implies Y", at which point, if you could imagine the variables ran "backwards" (unification was not explained) the outcome might start to seem _possible_. I expect the lecturer was as baffled by their presentation as we were.
In general, it left the rest of the class believing quite strongly that languages other than Java were impossible to use and generally a bad move. I may have been relatively bitter in the course evaluation by the end.
Y_Y•13h ago
Patterns might appear to the enlighted on the zeroth or first instance, but even the mortal must notice them after several goes. The magic of lisp is that if you notice yourself doing anything more than once you can go ahead and abstract it out.
Not everything needs to be lifted to functional valhalla of course, but not factoring out e.g. map and filter requires (imho) a wilful ignorance of the sort that no teacher should countenance. I think it's bad professional practise, bad pedagogy, and a bad time overall. I will die on this hill.
eru•2h ago
turtletontine•9h ago
So I get why a professor wouldn’t jump in with maps and folds. First, you need to make students solve a simple problem, then another. At the third problem, they might start to notice a pattern - that’s when you say gee your right there must be a better way to do this, and introduce maps and folds. The top 10% of the class will have been rolling their eyes the whole time, thinking well duh this is so boring. But most students seem to need their hand held through this whole process. And today, of course, most students are probably just having LLMs do their homework and REALLY learn nothing
kstrauser•9h ago
smadge•11h ago
[1] https://people.willamette.edu/~fruehr/haskell/evolution.html
smadge•11h ago
JadeNB•10h ago
widforss•6h ago