Logs: freenode/#haskell
| 2020-10-22 22:47:13 | → | poljar1 joins (~poljar@93-143-177-96.adsl.net.t-com.hr) |
| 2020-10-22 22:47:54 | <hekkaidekapus> | fraktor: It is probably not a good idea to roll your own float parser. Background: |
| 2020-10-22 22:48:03 | <int-e> | Guest18: I'm vaguely aware that such sites exist. Does tio.run do Haskell? |
| 2020-10-22 22:48:08 | × | Tario quits (~Tario@201.192.165.173) (Ping timeout: 272 seconds) |
| 2020-10-22 22:48:10 | <hekkaidekapus> | @where floating-point -- fraktor |
| 2020-10-22 22:48:10 | <lambdabot> | "What Every Programmer Should Know About Floating-Point Arithmetic" at <http://floating-point-gui.de/> and "What Every Computer Scientist Should Know About Floating-Point Arithmetic" by David |
| 2020-10-22 22:48:10 | <lambdabot> | Goldberg in 1991 at <http://docs.sun.com/source/806-3568/ncg_goldberg.html> and <http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.102.244> |
| 2020-10-22 22:48:42 | <hekkaidekapus> | fraktor: But you could try <https://hackage.haskell.org/package/megaparsec-9.0.0/docs/Text-Megaparsec-Char-Lexer.html#v:float> |
| 2020-10-22 22:49:24 | × | poljar quits (~poljar@93-139-70-179.adsl.net.t-com.hr) (Ping timeout: 265 seconds) |
| 2020-10-22 22:49:28 | → | Tario joins (~Tario@201.192.165.173) |
| 2020-10-22 22:50:18 | <Guest18> | int-e: it does |
| 2020-10-22 22:50:30 | <Guest18> | I hope it handles IO better than repl.it |
| 2020-10-22 22:50:32 | <Guest18> | thank you |
| 2020-10-22 22:51:26 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 256 seconds) |
| 2020-10-22 22:51:53 | <fraktor> | hekkaidekapus: So what I'm doing is using Parsec to determine which characters are part of the float and then `read`, so it's still pretty straightforward. |
| 2020-10-22 22:52:18 | → | olligobber joins (olligobber@gateway/vpn/privateinternetaccess/olligobber) |
| 2020-10-22 22:52:40 | <Guest18> | Another question: if i have two ints, and wanted to divide them (not div, but /) why won't haskell let me? |
| 2020-10-22 22:52:51 | <Guest18> | If you need more context |
| 2020-10-22 22:53:28 | <Guest18> | I have a function that counts how many letters are different in two given strings. For example "hello" and "hellq" would be 1 |
| 2020-10-22 22:53:57 | <Guest18> | And I use genericLength to get the length of those strings |
| 2020-10-22 22:54:10 | <Guest18> | But for some reason it won't let me divide them |
| 2020-10-22 22:54:24 | <int-e> | :t genericLength |
| 2020-10-22 22:54:25 | <lambdabot> | Num i => [a] -> i |
| 2020-10-22 22:54:35 | → | denisse joins (~spaceCat@gateway/tor-sasl/alephzer0) |
| 2020-10-22 22:55:05 | × | amagi_ quits (~amagi@113.101.23.223) (Ping timeout: 240 seconds) |
| 2020-10-22 22:55:20 | → | jedws joins (~jedws@101.184.148.229) |
| 2020-10-22 22:56:04 | <Guest18> | Ok, so the typeclass is Num, and so if i make the first function also return a num, it should work? |
| 2020-10-22 22:56:16 | <bliminse> | Guest18: to divide 2 ints with / call fromIntegral on each of them |
| 2020-10-22 22:56:32 | <hekkaidekapus> | fraktor: I don’t understand well what you’re trying to do. Do you want to extract sub-strings that could be converted to floats? |
| 2020-10-22 22:56:42 | → | texasmynsted joins (~texasmyns@104.140.52.115) |
| 2020-10-22 22:57:00 | <int-e> | Something doesn't add up. Anyway, the usual conversion functions are: fromIntegral, realToFrac, and floor/round/ceiling to get back to integers. |
| 2020-10-22 22:57:18 | → | amagi joins (~amagi@113.101.23.223) |
| 2020-10-22 22:57:21 | → | texasmyn_ joins (~texasmyns@104.140.52.115) |
| 2020-10-22 22:57:33 | <Guest18> | Actually, it worked just by putting the Num constraint on the first functrion |
| 2020-10-22 22:58:40 | → | tromp joins (~tromp@dhcp-077-249-230-040.chello.nl) |
| 2020-10-22 22:58:42 | × | texasmyn_ quits (~texasmyns@104.140.52.115) (Client Quit) |
| 2020-10-22 22:58:45 | → | rotaerk joins (rotaerk@2600:3c02::f03c:91ff:fe70:4a45) |
| 2020-10-22 22:58:55 | <Guest18> | https://pastebin.pl/view/7e4a65f8 |
| 2020-10-22 22:58:58 | <Guest18> | For reference |
| 2020-10-22 22:59:02 | → | texasmyn_ joins (~texasmyns@104.140.52.115) |
| 2020-10-22 22:59:45 | <Guest18> | It should calculate the percentage to which the second string is like the first |
| 2020-10-22 23:00:00 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-10-22 23:00:04 | <Guest18> | It takes a key string, and several other strings |
| 2020-10-22 23:00:07 | × | texasmynsted quits (~texasmyns@104.140.52.115) (Read error: Connection reset by peer) |
| 2020-10-22 23:00:26 | <Guest18> | For every one, if the percentage is bigger than 0.9, it prints pass otherwise fail |
| 2020-10-22 23:00:49 | × | mbomba quits (~mbomba@142.114.9.241) (Quit: WeeChat 2.9) |
| 2020-10-22 23:00:59 | × | conal quits (~conal@66.115.157.144) (Quit: Computer has gone to sleep.) |
| 2020-10-22 23:01:16 | <Guest18> | Wait, that's not the right code |
| 2020-10-22 23:01:38 | <Guest18> | https://pastebin.pl/view/49dd7475 |
| 2020-10-22 23:01:45 | <Guest18> | This is the working version |
| 2020-10-22 23:01:53 | × | texasmyn_ quits (~texasmyns@104.140.52.115) (Client Quit) |
| 2020-10-22 23:02:24 | <Guest18> | The key and the other strings are guaranteed to be of the same length |
| 2020-10-22 23:02:56 | → | conal joins (~conal@66.115.157.144) |
| 2020-10-22 23:03:13 | <Guest18> | I know I could have done better, maybe do the nums function with a fold or something, but i had a few minutes to do this |
| 2020-10-22 23:03:20 | × | seanvert quits (~user@177.84.244.242) (Ping timeout: 256 seconds) |
| 2020-10-22 23:03:24 | × | tromp quits (~tromp@dhcp-077-249-230-040.chello.nl) (Ping timeout: 256 seconds) |
| 2020-10-22 23:04:30 | <Guest18> | Suggestions? |
| 2020-10-22 23:05:06 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 256 seconds) |
| 2020-10-22 23:05:07 | × | vk3wtf quits (~doc@14-202-30-62.static.tpgi.com.au) (Quit: WeeChat 2.7.1) |
| 2020-10-22 23:05:37 | → | vk3wtf joins (~doc@14-202-30-62.static.tpgi.com.au) |
| 2020-10-22 23:10:53 | × | jiribenes quits (~jiribenes@rosa.jiribenes.com) (Remote host closed the connection) |
| 2020-10-22 23:11:11 | → | geowiesnot joins (~user@87-89-181-157.abo.bbox.fr) |
| 2020-10-22 23:12:25 | <Guest18> | num key sub = foldr (\(x,y) b -> if x == y then b+1 else b) 0 $ zip key sub -- i reckon this is better |
| 2020-10-22 23:12:51 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection) |
| 2020-10-22 23:13:02 | × | xff0x quits (~fox@2001:1a81:52d2:ca00:522a:154a:cc26:5e43) (Ping timeout: 260 seconds) |
| 2020-10-22 23:13:14 | × | dansho quits (~dansho@ip68-108-167-185.lv.lv.cox.net) (Remote host closed the connection) |
| 2020-10-22 23:13:37 | → | xff0x joins (~fox@2001:1a81:52d2:ca00:c409:1d88:453d:35d6) |
| 2020-10-22 23:13:39 | → | dansho joins (~dansho@ip68-108-167-185.lv.lv.cox.net) |
| 2020-10-22 23:15:16 | × | elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Quit: Leaving) |
| 2020-10-22 23:15:46 | × | dqd quits (id@wikipedia/dqd) (Ping timeout: 246 seconds) |
| 2020-10-22 23:15:49 | × | StoneToad quits (~StoneToad@199-167-119-164.ppp.storm.ca) (Ping timeout: 264 seconds) |
| 2020-10-22 23:16:15 | → | StoneToad_ joins (~StoneToad@199-167-119-164.ppp.storm.ca) |
| 2020-10-22 23:16:18 | <Guest18> | Really, any suggestions whatsoever are welcome |
| 2020-10-22 23:17:01 | <hekkaidekapus> | fraktor: I’m going away. In the meantime, here is something to chew on. Your bespoke parser would recognise "+45.6". Now try Text.Megaparsec.Char.Lexer.float with that to see what you get. Also: |
| 2020-10-22 23:17:18 | <hekkaidekapus> | > isIEE 45.6 -- fraktor |
| 2020-10-22 23:17:20 | <lambdabot> | error: |
| 2020-10-22 23:17:20 | <lambdabot> | • Variable not in scope: isIEE :: t0 -> t |
| 2020-10-22 23:17:20 | <lambdabot> | • Perhaps you meant ‘isIEEE’ (imported from Prelude) |
| 2020-10-22 23:17:35 | <hekkaidekapus> | > isIEEE 45.6 -- fraktor |
| 2020-10-22 23:17:37 | <lambdabot> | True |
| 2020-10-22 23:17:43 | <hekkaidekapus> | > isIEEE +45.6 -- fraktor |
| 2020-10-22 23:17:45 | <lambdabot> | error: |
| 2020-10-22 23:17:45 | <lambdabot> | • No instance for (Fractional (Double -> Bool)) |
| 2020-10-22 23:17:45 | <lambdabot> | arising from a use of ‘e_1456’ |
| 2020-10-22 23:19:43 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-22 23:20:15 | <int-e> | :t isIEEE |
| 2020-10-22 23:20:17 | <lambdabot> | RealFloat a => a -> Bool |
| 2020-10-22 23:22:43 | × | conal quits (~conal@66.115.157.144) (Quit: Computer has gone to sleep.) |
| 2020-10-22 23:24:00 | → | dqd joins (id@wikipedia/dqd) |
| 2020-10-22 23:24:35 | → | conal joins (~conal@66.115.157.144) |
| 2020-10-22 23:25:30 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 272 seconds) |
| 2020-10-22 23:26:47 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:ccf3:9e4f:a615:179a) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-10-22 23:28:37 | → | invaser joins (~Thunderbi@31.148.23.125) |
| 2020-10-22 23:29:28 | × | conal quits (~conal@66.115.157.144) (Client Quit) |
| 2020-10-22 23:30:14 | × | christo quits (~chris@81.96.113.213) (Remote host closed the connection) |
| 2020-10-22 23:31:38 | → | texasmynsted joins (~texasmyns@104.140.52.115) |
| 2020-10-22 23:32:22 | × | fraktor quits (~walt@129.93.191.18) (Quit: WeeChat 2.8) |
| 2020-10-22 23:33:56 | × | falafel quits (~falafel@71-34-132-121.clsp.qwest.net) (Ping timeout: 256 seconds) |
| 2020-10-22 23:34:02 | × | ensyde quits (~ensyde@2600:1702:2e30:1a40:693a:f19:42e4:5751) (Ping timeout: 260 seconds) |
| 2020-10-22 23:35:39 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
All times are in UTC.