Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-04-26 17:05:24 × idhugo_ quits (~idhugo@80-62-116-231-mobile.dk.customer.tdc.net) (Ping timeout: 268 seconds)
2021-04-26 17:06:00 amerigo joins (uid331857@gateway/web/irccloud.com/x-ihzxbomyjkylusyy)
2021-04-26 17:06:07 × heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2021-04-26 17:06:32 × hypercube quits (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com) (Quit: WeeChat 3.1)
2021-04-26 17:07:04 × ddellac__ quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 252 seconds)
2021-04-26 17:07:21 × nicholasbulka quits (~nicholasb@2601:900:4301:da0:58e6:3a0a:96a:ca2c) (Remote host closed the connection)
2021-04-26 17:08:59 × pavonia quits (~user@unaffiliated/siracusa) (Quit: Bye!)
2021-04-26 17:10:16 × elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Ping timeout: 260 seconds)
2021-04-26 17:10:19 × fjMSX quits (~egp_@2.95.117.163) (Quit: EXIT)
2021-04-26 17:11:56 heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-04-26 17:13:41 <tempate> Is it possible to do a map over two lists at once?
2021-04-26 17:14:17 <monochrom> Perhaps zipWith is what you want.
2021-04-26 17:15:24 <tempate> I have two lists, one withs xs and another with ys, and I want to apply the same function to each pair. So if xs = [1,2,3] and ys = [4,5,6] y want [f(1, 4), f(2, 5), f(3, 6)]
2021-04-26 17:15:39 <monochrom> zipWith
2021-04-26 17:16:24 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-26 17:16:59 <tempate> Great, thanks, monochrom
2021-04-26 17:17:25 hypercube joins (~hypercube@2603-6011-f901-9e5b-0000-0000-0000-08cf.res6.spectrum.com)
2021-04-26 17:18:09 <ski> map f (zip xs ys) = zipWith (curry f) xs ys
2021-04-26 17:18:30 anandprabhu joins (~anandprab@94.203.71.143)
2021-04-26 17:19:07 zmijunkie joins (~Adium@109.90.32.89)
2021-04-26 17:19:10 <tempate> What's curry?
2021-04-26 17:19:18 <ski> > map f (zip [1,2,3] [4,5,6]) :: [Expr]
2021-04-26 17:19:20 <lambdabot> [f (1,4),f (2,5),f (3,6)]
2021-04-26 17:19:27 <ski> > zipWith f [1,2,3] [4,5,6] :: [Expr]
2021-04-26 17:19:28 <lambdabot> [f 1 4,f 2 5,f 3 6]
2021-04-26 17:19:36 <ski> > zipWith (curry f) [1,2,3] [4,5,6] :: [Expr]
2021-04-26 17:19:37 <lambdabot> [f (1,4),f (2,5),f (3,6)]
2021-04-26 17:19:48 <tempate> oh, I see
2021-04-26 17:19:52 <tempate> great, thanks a lot
2021-04-26 17:19:58 <ski> `curry' converts from the `blah (x,y)' form to the `bleh x y' form
2021-04-26 17:20:14 <ski> iow, `curry blah' would be `bleh', here
2021-04-26 17:20:20 <ski> @src curry
2021-04-26 17:20:20 <lambdabot> curry f x y = f (x, y)
2021-04-26 17:20:23 × rodriga quits (~quassel@134.204.25.66) (Read error: Connection reset by peer)
2021-04-26 17:20:31 rodriga joins (~quassel@134.204.25.66)
2021-04-26 17:20:40 Sgeo_ joins (~Sgeo@ool-18b9875e.dyn.optonline.net)
2021-04-26 17:20:44 × Sgeo quits (~Sgeo@ool-18b9875e.dyn.optonline.net) (Read error: Connection reset by peer)
2021-04-26 17:21:05 zmijunkie1 joins (~Adium@87.123.51.242)
2021-04-26 17:21:12 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 240 seconds)
2021-04-26 17:21:18 × stree quits (~stree@68.36.8.116) (Ping timeout: 260 seconds)
2021-04-26 17:21:39 × zmijunkie1 quits (~Adium@87.123.51.242) (Client Quit)
2021-04-26 17:21:57 zmijunkie1 joins (~Adium@87.123.51.242)
2021-04-26 17:22:18 <tempate> I'm now realizing that it's more complicated than what I said. The function I gave, f, returns a function. So what I would really like would be (h = (g = f(1, 4)) (2, 5)) (3, 6)
2021-04-26 17:22:21 tzh joins (~tzh@c-24-21-73-154.hsd1.wa.comcast.net)
2021-04-26 17:23:27 <ski> what would you like to do with the returned functions ?
2021-04-26 17:23:34 × zmijunkie quits (~Adium@109.90.32.89) (Ping timeout: 265 seconds)
2021-04-26 17:23:43 <tempate> I would just like to return the last function
2021-04-26 17:23:50 <tempate> The result of h(3,6)
2021-04-26 17:23:52 Sheilong joins (uid293653@gateway/web/irccloud.com/x-rcsvshxqwuthdgbo)
2021-04-26 17:23:55 jrp joins (0550efe4@5.80.239.228)
2021-04-26 17:24:01 <ski> so you don't care about the previous pairs at all ?
2021-04-26 17:24:10 <tempate> I don't, no
2021-04-26 17:24:20 <ski> are the two lists of the same length ?
2021-04-26 17:24:24 <tempate> I only cair about the previous pairs of xs and ys to generate the previous functions that lead up to h
2021-04-26 17:24:29 × johncena quits (5c0cd4ac@host-92-12-212-172.as13285.net) (Quit: Connection closed)
2021-04-26 17:24:31 <ski> hm
2021-04-26 17:24:31 <tempate> They are, yes
2021-04-26 17:25:01 <ski> do you want to use the function generated from one pair, in order to process the next pair ?
2021-04-26 17:25:11 <tempate> Yes, that's it
2021-04-26 17:25:14 <monochrom> I would be interested in seeing an actual example of f, and in fact an actual example of the two input lists too.
2021-04-26 17:25:23 <ski> sounds like you maybe want a fold, then
2021-04-26 17:25:41 <tempate> I can explain in detail if you want
2021-04-26 17:25:44 <ski> yea, a concrete example would help
2021-04-26 17:26:20 <monochrom> Not so much detail as precision and unambiguity.
2021-04-26 17:28:25 <tempate> ok, I have to write a 8-puzzle solver for university, and one of the constraints is to represent boards as newtype Board = T (Position, Position -> Maybe Int), where type Position = (Int, Int), and Maybe Int represents the value of the tile. So boards are a tuple: their first value is the position of the empty square and the second value is a function that, given a position, returns the value of its tile.
2021-04-26 17:28:35 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-04-26 17:29:19 <tempate> I have to write a function that takes a list of tiles in left-to-right descending order and returns a board
2021-04-26 17:29:54 <tempate> I have a function that gives the final board, the objective, one could say
2021-04-26 17:30:11 <jrp> Hi, just trying to figure out where in the stack to include haskellne (readInput) transformer:   I start with a working `type Forth w a r = ExceptT VMSignal (StateT (VM w a) IO) r` and I have placed it with `type Forth w a r = ExceptT VMSignal (StateT (VM w a) (InputT IO)) r`.  All compiles fine (after replacing the getLine and wrapping a
2021-04-26 17:30:11 <jrp> `runInputBehavior` around the previous `runStateT`.   However, the app seems to run just as before (ie, with no line editing/history enhancements).  Any suggestions as to what I might look at, pls?
2021-04-26 17:30:25 <tempate> So I thought that I could make new position-functions by changing the final board's one tile at a time
2021-04-26 17:30:28 <ski> "the position of the empty square" ?
2021-04-26 17:31:22 <tempate> Well, in an 8-puzzle there are 8 tiles and an empty tile (or empty square) in a 3x3 board, and you have to rearrange them so they end up in order
2021-04-26 17:31:28 × zmijunkie1 quits (~Adium@87.123.51.242) (Quit: Leaving.)
2021-04-26 17:31:45 zmijunkie joins (~Adium@87.123.51.242)
2021-04-26 17:32:10 <ski> ah, right
2021-04-26 17:32:44 <ski> well, what you sketched certainly seems doable
2021-04-26 17:33:32 <tempate> Yeah, I think so, but I'm not too confident with Haskell
2021-04-26 17:33:42 × Narinas quits (~Narinas@187-178-93-112.dynamic.axtel.net) (Read error: Connection reset by peer)
2021-04-26 17:33:44 <ski> i would probably opt for `foldr'
2021-04-26 17:33:57 stree joins (~stree@68.36.8.116)
2021-04-26 17:34:37 <ski> (or, an explicit recursion, amounting to the same thing)
2021-04-26 17:35:08 <tempate> An explicit recursion felt a bit more dirty to me
2021-04-26 17:35:16 <tempate> Although now that I think about it, it may be alright
2021-04-26 17:35:17 <ski> for each tile, you'd need to know its corresponding position
2021-04-26 17:35:31 frozenErebus joins (~frozenEre@37.231.244.249)
2021-04-26 17:35:40 <tempate> Yes, that I know
2021-04-26 17:35:42 Narinas joins (~Narinas@187-178-93-112.dynamic.axtel.net)
2021-04-26 17:36:22 <ski> one way would be to divide the list of tiles, into a list of rows of tiles. another would be to `zip' the tiles with their positions. a third would be to pass the current tile position as an additional argument to the processing function
2021-04-26 17:37:45 <jrp> @unmtl ExceptT VMSignal (StateT (VM w a) (InputT IO)) r
2021-04-26 17:37:45 <lambdabot> VM w a -> InputT IO (Either VMSignal r, VM w a)
2021-04-26 17:37:47 <tempate> Alright, I'm going to give a try to the explicit approach
2021-04-26 17:37:49 fivebox joins (x@unaffiliated/fivebox)
2021-04-26 17:38:23 <ski> (if one were thinking about efficiency, one could wonder if perhaps one shouldn't construct the board functions as sequentially scanning for the appropriate position .. but that's a complication, and the board is so small that it would hardly matter anyway)
2021-04-26 17:39:48 <tempate> Not sure I get what you mean by sequentially scanning
2021-04-26 17:39:59 ddellac__ joins (ddellacost@gateway/vpn/mullvad/ddellacosta)
2021-04-26 17:40:06 × frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 240 seconds)
2021-04-26 17:40:12 × anandprabhu quits (~anandprab@94.203.71.143) (Quit: Konversation terminated!)
2021-04-26 17:40:23 <ski> i mean the function that is constructed, by passing from one tile to the next, updating the function sequentially
2021-04-26 17:40:40 <ski> an alternative would be to construct the function as a tree, perhaps

All times are in UTC.