Logs: freenode/#haskell
| 2021-04-20 21:06:46 | <lambdabot> | [2,3] |
| 2021-04-20 21:07:11 | × | Guest78317 quits (~laudiacay@67.176.215.84) (Ping timeout: 240 seconds) |
| 2021-04-20 21:08:06 | × | malumore_ quits (~malumore@151.62.126.110) (Ping timeout: 240 seconds) |
| 2021-04-20 21:08:20 | <edwardk> | so basically the definition of compare for lists matches on the two lists, walks through them if they both have elements it compares the heads and proceeeds recursively if they are the same, if they both are empty they are the same, and if one has elements and the other does not then the one with elements is considered greater. just like how 'dogfood' comes after 'dog' in the dictionary. |
| 2021-04-20 21:08:22 | <ski> | > let x:xs = [1,2,3] in (x,xs) |
| 2021-04-20 21:08:24 | <lambdabot> | (1,[2,3]) |
| 2021-04-20 21:09:18 | <tatsumaru> | so basically it interchanges between different definitions of greater depending on the case? |
| 2021-04-20 21:09:43 | <tatsumaru> | sometimes it's greater because 3 > 2 and sometimes it's greater because the list is longer |
| 2021-04-20 21:09:45 | <monochrom> | I don't understand that question. |
| 2021-04-20 21:10:05 | × | geekosaur quits (930099da@rrcs-147-0-153-218.central.biz.rr.com) (Quit: Connection closed) |
| 2021-04-20 21:10:21 | <edwardk> | the only time it ever 'compares list lengths' is when one ran out of elements completely. |
| 2021-04-20 21:10:23 | → | geekosaur joins (930099da@rrcs-147-0-153-218.central.biz.rr.com) |
| 2021-04-20 21:10:25 | <xsperry> | tatsumaru, what would you prefer? that smaller list is greater? that an error is thrown? |
| 2021-04-20 21:10:36 | <xsperry> | (or rather returned) |
| 2021-04-20 21:10:46 | <geekosaur> | and why? |
| 2021-04-20 21:11:19 | <tatsumaru> | I am not making preferences just trying to figure it out |
| 2021-04-20 21:11:38 | → | ubert joins (~Thunderbi@178.115.130.126.wireless.dyn.drei.com) |
| 2021-04-20 21:11:46 | <monochrom> | And there are two "it"s that clearly refer to two unrelated things so the question reflects that you are thinking unclearly. |
| 2021-04-20 21:11:46 | <tatsumaru> | in terms of what would make most sense to me as a noob programmer is that it would throw an error because one list has more indexes than the other |
| 2021-04-20 21:12:07 | × | hyperisco quits (~hyperisco@d192-186-117-226.static.comm.cgocable.net) (Ping timeout: 265 seconds) |
| 2021-04-20 21:12:43 | → | nut joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) |
| 2021-04-20 21:12:50 | → | barakkl1993 joins (~barakkley@2.55.154.74) |
| 2021-04-20 21:12:51 | <ski> | each list can be either empty or non-empty. since there's two lists, that makes four combinations. both empty means they lists are equal. one empty and one non-empty means the empty one is less than the non-empty one. both non-empty .. then we compare the first element of both lists. only if they're equal do we continue to compare the tails of the two lists |
| 2021-04-20 21:13:02 | <nut> | what is the time complexity of list join (++) ? |
| 2021-04-20 21:13:12 | <ski> | join ? |
| 2021-04-20 21:13:17 | <nut> | concat |
| 2021-04-20 21:13:39 | <edwardk> | that isn't terribly useful if you want to, say, use those lists as a key in a map. here we want 'Ord' to give us a comparison that is a total function that tells us if xs < ys, if xs == ys, or if xs > ys. that is the role served by compare, by <, <=, =>, >, ==, /= in haskell. |
| 2021-04-20 21:13:40 | <ski> | `xs ++ ys' takes time proportional to the length of `xs' |
| 2021-04-20 21:13:42 | <monochrom> | The time cost of xs++ys is proportional to the length of xs. |
| 2021-04-20 21:13:43 | <edwardk> | they are 'total' |
| 2021-04-20 21:14:08 | <xsperry> | tatsumaru, sort function uses <. if Ord for list was defined the way you propose, you could only sort a list of strings if all the strings were of the same length. |
| 2021-04-20 21:14:17 | <monochrom> | ys and xs++ys can share the ys part. |
| 2021-04-20 21:14:23 | <tatsumaru> | if longer lists are greater then why is [2, 2] > [3] false ? |
| 2021-04-20 21:14:40 | <monochrom> | 2<3 |
| 2021-04-20 21:14:51 | <monochrom> | GG |
| 2021-04-20 21:14:53 | <ski> | because the remainder of the lists are only considered, in case the head elements differ |
| 2021-04-20 21:14:57 | <nut> | ski: i see, you'd have to traverse xs |
| 2021-04-20 21:15:06 | <monochrom> | ski: Eqaul! |
| 2021-04-20 21:15:12 | <edwardk> | on the other hand you could well come up with a class for 'partial orders' where the question a <=? b = False and b <=? a = False at the same time is perfectly acceptable. no 'errors' need be thrown, then you could say for that that two lists can only compare as <=? if, say they are exactly the same length _and_ say, every single element compares as <= its corresponding sibling in the other list. |
| 2021-04-20 21:15:22 | <monochrom> | nut: It also has to clone xs. |
| 2021-04-20 21:15:35 | <tatsumaru> | so this is what puzzles me whether the boolean output is based on the total length of the list or on comparing each individual integers to each other |
| 2021-04-20 21:15:40 | <edwardk> | tatsumaru: why does 'catfood' come before 'dog' in the dictionary? |
| 2021-04-20 21:15:42 | <ski> | in `[2,2] > [3]', we have `2 < 3', hence the list comparision is `False'. we never get to comparing the tails, per `[2] > []' |
| 2021-04-20 21:16:16 | <tatsumaru> | edwardk ok this made it clearer, basically both things matter |
| 2021-04-20 21:17:24 | × | geekosaur quits (930099da@rrcs-147-0-153-218.central.biz.rr.com) (Quit: Connection closed) |
| 2021-04-20 21:17:36 | × | nut quits (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) (Remote host closed the connection) |
| 2021-04-20 21:17:41 | → | geekosaur joins (930099da@rrcs-147-0-153-218.central.biz.rr.com) |
| 2021-04-20 21:18:24 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 265 seconds) |
| 2021-04-20 21:18:26 | × | ubert quits (~Thunderbi@178.115.130.126.wireless.dyn.drei.com) (Ping timeout: 260 seconds) |
| 2021-04-20 21:18:50 | <ski> | tatsumaru : corresponding elements are compared, successively. we only continue this comparision, as long as previous corresponding element comparisions have turned out to compare equal, and (obviously) as long as there's more elements of both lists to compare with each other. so, as soon as one (or both) lists end, this process also stops. but it also stops if an element comparision compares not equal |
| 2021-04-20 21:19:14 | <tatsumaru> | just realized you could actually do this with char as well "catfood" < "dog" |
| 2021-04-20 21:19:20 | <edwardk> | think of this as walking through both lists discarding common prefixes. when you're done discarding the common prefix, the next elements if they exist disagree. which one comes first? if they both don't exist, its becauseyour lists are the same, if one exists and the other doesn't, its because you are looking at something like the "dog" vs "dogfood" |
| 2021-04-20 21:19:21 | <ski> | yep |
| 2021-04-20 21:20:15 | <ski> | tatsumaru : as an exercise, you could define `lessThan :: Ord a => [a] -> [a] -> Bool' yourself ? |
| 2021-04-20 21:21:01 | <tatsumaru> | I am not sure what that means yet I am literally on chapter 1 of the book. |
| 2021-04-20 21:21:09 | × | mikoto-chan quits (~anass@gateway/tor-sasl/mikoto-chan) (Ping timeout: 240 seconds) |
| 2021-04-20 21:21:20 | <tatsumaru> | is this a function definition |
| 2021-04-20 21:21:26 | <ski> | yes, it would be |
| 2021-04-20 21:21:48 | <geekosaur> | well, strictly speaking that was the type signature for a function |
| 2021-04-20 21:22:07 | <ski> | (what i gave would be the corresponding type signature. if you prefer, you could do e.g. `lessThan :: [Integer] -> [Integer] -> Bool' instead. or `lessThan :: [Char] -> [Char] -> Bool') |
| 2021-04-20 21:23:17 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2021-04-20 21:24:31 | × | knupfer quits (~Thunderbi@200116b82b97f00088ad36c7c6f65050.dip.versatel-1u1.de) (Ping timeout: 245 seconds) |
| 2021-04-20 21:24:39 | <tatsumaru> | by the way is the new haskell 2020 spec going to be compatible with what I am learning right now? |
| 2021-04-20 21:24:52 | × | s00pcan quits (~chris@107.181.165.217) (Ping timeout: 240 seconds) |
| 2021-04-20 21:24:55 | <tatsumaru> | which is haskell 2010 |
| 2021-04-20 21:24:55 | <monochrom> | There is no Haskell 2020. |
| 2021-04-20 21:25:33 | × | rj quits (~x@gateway/tor-sasl/rj) (Ping timeout: 240 seconds) |
| 2021-04-20 21:25:35 | <tatsumaru> | hmm, the wiki says 'Haskell 2020 announced' preview release |
| 2021-04-20 21:26:56 | → | s00pcan joins (~chris@075-133-056-178.res.spectrum.com) |
| 2021-04-20 21:27:49 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 252 seconds) |
| 2021-04-20 21:27:51 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 245 seconds) |
| 2021-04-20 21:28:11 | → | olligobber joins (olligobber@gateway/vpn/privateinternetaccess/olligobber) |
| 2021-04-20 21:28:49 | → | ludi49 joins (~hryhorij@156.17.231.95) |
| 2021-04-20 21:29:00 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-04-20 21:32:17 | → | danvet_ joins (~danvet@212-51-149-181.fiber7.init7.net) |
| 2021-04-20 21:34:09 | × | rj quits (~x@gateway/tor-sasl/rj) (Remote host closed the connection) |
| 2021-04-20 21:34:21 | → | jesystani joins (~thorn@2404:4404:17f1:4900:819e:dd03:7c1b:1df4) |
| 2021-04-20 21:34:22 | → | Guest78317 joins (~laudiacay@67.176.215.84) |
| 2021-04-20 21:34:31 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-04-20 21:35:09 | × | lawr3nce quits (~lawr3nce@gateway/tor-sasl/lawr3nce) (Ping timeout: 240 seconds) |
| 2021-04-20 21:35:21 | × | aidecoe quits (~aidecoe@unaffiliated/aidecoe) (Remote host closed the connection) |
| 2021-04-20 21:36:14 | → | Neuromancer joins (~Neuromanc@unaffiliated/neuromancer) |
| 2021-04-20 21:38:24 | × | heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2021-04-20 21:38:36 | × | Guest78317 quits (~laudiacay@67.176.215.84) (Ping timeout: 252 seconds) |
| 2021-04-20 21:39:21 | × | michalz quits (~user@185.246.204.61) (Remote host closed the connection) |
| 2021-04-20 21:41:11 | × | ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection) |
| 2021-04-20 21:41:46 | → | ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net) |
| 2021-04-20 21:43:17 | → | myShoggoth joins (~myShoggot@75.164.11.109) |
| 2021-04-20 21:43:57 | ← | tatsumaru parts (~tatsumaru@85.196.189.103) () |
| 2021-04-20 21:46:26 | × | ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 240 seconds) |
| 2021-04-20 21:47:09 | → | maroloccio joins (~marolocci@pousada3ja.mma.com.br) |
| 2021-04-20 21:48:00 | → | geiger_ joins (~geiger@90.212.77.86) |
| 2021-04-20 21:50:47 | × | geiger quits (~geiger@90.212.77.86) (Ping timeout: 265 seconds) |
| 2021-04-20 21:54:11 | × | danvet_ quits (~danvet@212-51-149-181.fiber7.init7.net) (Ping timeout: 240 seconds) |
| 2021-04-20 21:54:51 | × | danvet quits (~Daniel@2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa) (Ping timeout: 260 seconds) |
| 2021-04-20 21:56:25 | × | Lowl3v3l quits (~Lowl3v3l@dslb-002-207-103-026.002.207.pools.vodafone-ip.de) (Ping timeout: 252 seconds) |
| 2021-04-20 21:58:35 | → | nut joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) |
| 2021-04-20 21:59:10 | <nut> | if (++) in Data.List is too slow, what data structure to consider for fast concat ? |
| 2021-04-20 21:59:55 | <monochrom> | Data.Sequence.Seq |
| 2021-04-20 22:00:11 | <nut> | thanks |
All times are in UTC.