Not logged in. · Lost password · Register

 Member since Apr 2018 28 posts 2018-10-27, 03:32   #2   Is it fine to solve the permutations without the hint? The hint confuses me more than it helps. Also: Any hints on how to hand in stuff on studon without getting the pesky .sec ending? This post was edited on 2018-10-27, 05:04 by Stella.
 Member since Jul 2016 93 posts 2018-10-27, 20:56   #3   Regarding Question 1.2.3: What is a symmetrical binary tree? I couldn't find any definition in the lecture notes.
 ModKrypt Tutor WS19/20 Member since Oct 2014 106 posts 2018-10-28, 10:24   #4   In reply to post #2 +1 Stella Is it fine to solve the permutations without the hint? The hint confuses me more than it helps. Yes, as long as it written in Prolog and it works, you can solve the problem however you like. You just might get lost in the process, that's why we gave the hint. But I totally agree that the way it is written may confuse you, so you may hear it with my words. The helper function takeout(X,LSA,LSB) might be helpful, as it takes the element X and a List LSB and "returns" a List LSA, where X was put into the list. By re-evaluating the function (space bar or using the ";"), you should get a different LSA, meaning that X is at another location in the list. swipl example: ?- takeout(1,X,[2,3,4]). X = [1, 2, 3, 4] ; X = [2, 1, 3, 4] ; X = [2, 3, 1, 4] ; X = [2, 3, 4, 1] ; false. (This also shows the "magic" of Prolog, since the definition of the function "changes" by changing the variable parameters. But what you should learn from here is, that the definition does not change, since both descriptions of takeout are correct. Once you realize this, the only two things left you need to become good at Prolog is a good understanding of recursion and the will to learn Prolog's syntax )  Also: Any hints on how to hand in stuff on studon without getting the pesky .sec ending? No, not really. What file format did you hand in? "Debugging is like doing surgery by randomly squeezing stuff in a patient's body and going like 'lmao tell me when this guy stops breathing'." -- Orteil, Creator of Cookie-Clicker This post was edited 2 times, last on 2018-10-28, 10:53 by tyr.
 Member since Oct 2016 806 posts 2018-10-28, 10:51   #5   +1 Stella Also: Any hints on how to hand in stuff on studon without getting the pesky .sec ending? Nope, studon just does that. Nevermind that, the tutors will have to take care of that unfortunately. Regarding Question 1.2.3: What is a symmetrical binary tree? I couldn't find any definition in the lecture notes. If you google "symmetrical binary tree", you will find two definitions; one being on the structure of the tree and one being on the values of the tree. Only one of them makes sense in the context of the exercise
 Member since Oct 2018 4 posts 2018-10-29, 19:33   #6   I have a general question regarding the prolog assignments. As far as I understood the exercise, we are not allowed to use any built-in functions. Is that correct? Or should we just not use the built-in functions that we are required to implement ourselves (i.e. "delete", "reverse") but can use others, such as "append"?
 Member since Oct 2016 806 posts 2018-10-30, 12:17   #7   As far as I understood the exercise, we are not allowed to use any built-in functions. Is that correct? Let me put it like that: You are not supposed to use any pre-defined functions on lists. But of course you'll need to pattern match lists, and I can't reasonably expect you to reimplement a pattern matching mechanism (bonus points if you do xD )
 Member since Oct 2018 10 posts 2018-11-02, 12:06   #8   One short question regarding the zip function: if zip() gets lists that differ by more than 1, how should it react? Or is it irrelevant and simply not specified? mfg
 Member since May 2014 48 posts 2018-11-02, 15:08   #9   Since the assignment says: The zip function takes two lists with lengths that differ at most by 1 I would assume, that any other case is irrelevant I have a question regarding myPermutation: is this function supposed to output false at the end? It's not on the sheet, but the permutation built-in also outputs false at the end
 ModKrypt Tutor WS19/20 Member since Oct 2014 106 posts 2018-11-02, 15:35   #10   Quote by Nash:Since the assignment says: The zip function takes two lists with lengths that differ at most by 1 I would assume, that any other case is irrelevant You are  right. I have a question regarding myPermutation: is this function supposed to output false at the end? Yes,  at least our solution does this "Debugging is like doing surgery by randomly squeezing stuff in a patient's body and going like 'lmao tell me when this guy stops breathing'." -- Orteil, Creator of Cookie-Clicker
 Member since Dec 2014 61 posts 2018-11-02, 16:33   #11   Should construct fail if the given list is not duplicate-free? E.g. should construct([1, 2, 3], T) and construct([1, 1, 2, 3], T) both yield the same result T = t(1, nil, t(2, nil, t(3, nil, nil))) or should the second one say "false"?
 Member since Oct 2016 806 posts 2018-11-02, 17:08   #12   In reply to post #9 I have a question regarding myPermutation: is this function supposed to output false at the end? This is Prologs default behaviour: For prolog, every query is "find a proof/substitution that makes the queried statement true". If it finds such a substitution, it will return that. If it doesn't it will return false. So basically any "function" (i.e. predicate) should return false if and only if no other solutions for the free variables in a query remain. if zip() gets lists that differ by more than 1, how should it react? By the above: Since you're not supposed to implement functionality for this case, Prolog would have to return false by default. Should construct fail if the given list is not duplicate-free? E.g. should construct([1, 2, 3], T) and construct([1, 1, 2, 3], T) both yield the same result T = t(1, nil, t(2, nil, t(3, nil, nil))) or should the second one say "false"? pff, to be honest, I didn't even consider that case, so either behavior is fine, since it's unspecified by the framing of the problem
 Member since May 2017 149 posts 2018-11-02, 18:24   #13   Quote by Exercise Sheet:Write a ProLog function construct that constructs a binary tree out of a list of (distinct) numbers [...] I guess we can assume that the given list is duplicate-free since the exercise sheet tells us it is a list of distinct numbers, right?
 Member since Oct 2016 806 posts 2018-11-02, 18:26   #14   I guess we can assume that the given list is duplicate-free since the exercise sheet tells us it is a list of distinct numbers, right? Yes, you can. I've interpreted the previous question as a sort-of fallback. What we care about is whether your predicate behaves as intended on "valid" inputs only -- I assume you know to throw exceptions in real-life situations
Close Smaller – Larger + Reply to this post:
Verification code: Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys:
Special characters:
Go to forum
Datenschutz | Kontakt