Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Problem with minimax with alpha beta pruning (Maxim Frolov) 2. Re: Lambda expression currying (Lawrence Bottorff) 3. Another currying and lambda question (Lawrence Bottorff) 4. Re: Another currying and lambda question (Francesco Ariis) 5. Re: Another currying and lambda question (Lawrence Bottorff) ---------------------------------------------------------------------- Message: 1 Date: Tue, 22 Dec 2020 13:18:56 +0000 From: Maxim Frolov <maxim.frolov...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Problem with minimax with alpha beta pruning Message-ID: <7fb37eab-89cd-4559-9c92-5dcb68c7f20b@Spark> Content-Type: text/plain; charset="utf-8" Got it. Thank you Kim-Ee! On 22 Dec 2020, 08:28 +0000, Kim-Ee Yeoh <k...@atamo.com>, wrote: > Hi Maxim, > > The scope of this question falls outside this beginners list, which tends > toward questions about haskell syntax (see other active thread). > > You will typically find more response on the haskell-cafe list, which you > might want to resend your query to. > > > On Mon, Dec 21, 2020 at 11:01 PM Maxim Frolov <maxim.frolov...@gmail.com> > > wrote: > > > Hi All, > > > > > > I am new to Haskell and got stuck while experimenting with minimax > > > algorithm (tic-tac-toe game). Just for learning I am trying to avoid > > > external modules and use only the standard Prelude library. > > > > > > Here is the code snippet: > > > > > > type Pos = (Int,Int) > > > -- Players are O (minimizing) and X (maximizing), B is for the draw > > > (blank), I and J are used for -INF and +INF respectively > > > data Player = I | O | B | X | J > > > deriving (Eq, Ord, Show) > > > type Grid = [(Pos,Player)] > > > data Tree a = Node a [Tree a] > > > deriving Show > > > > > > minimax :: Player -> Player -> Tree Grid -> Tree (Grid, Player) > > > minimax _ _ (Node g []) > > > | wins X g = Node (g,X) [] > > > | wins O g = Node (g,O) [] > > > | otherwise = Node (g,B) [] > > > minimax a b (Node g ts) > > > | turn g == X = > > > let ts' = [minimax alpha b t | t <- ts, alpha < b] > > > ps = [p | Node (_,p) _ <- ts'] > > > alpha = maximum (a:ps) > > > in Node (g, alpha) ts' > > > | turn g == O = > > > let ts' = [minimax a beta t | t <- ts, a < beta] > > > ps = [p | Node (_,p) _ <- ts'] > > > beta = minimum (b:ps) > > > in Node (g, beta) ts' > > > > > > > > > The function call is like: > > > > > > minimax I J tree > > > > > > > > > It looks like I got a recursion loop. Could someone advise how to > > > approach the problem? > > > > > > Thank you, > > > Max > > > > > > > > > _______________________________________________ > > > Beginners mailing list > > > Beginners@haskell.org > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- > -- Kim-Ee > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20201222/dec3b11e/attachment-0001.html> ------------------------------ Message: 2 Date: Tue, 22 Dec 2020 10:00:22 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Lambda expression currying Message-ID: <cafahfsueey9ez+vffdvmm2sj9d0wjy97uud_c2-s5jpbxsx...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Thanks, that's clearer now. On Tue, Dec 22, 2020 at 12:55 AM Francesco Ariis <fa...@ariis.it> wrote: > Hello Lawrence, > > Il 21 dicembre 2020 alle 23:59 Lawrence Bottorff ha scritto: > > addThree :: (Num a) => a -> a -> a -> a > > addThree = \x -> \y -> \z -> x + y + z > > […] > > > > But how is the beta reduction happening with addThree? > > Should be: > > addThree = (\x -> \y -> \z -> x + y + z) 1 2 3 > = (\y -> \z -> 1 + y + z) 2 3 beta > = (\z -> 1 + 2 + z) 3 beta > = 1 + 2 + 3 beta > = … > > Does that make sense? > —F > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20201222/771a0001/attachment-0001.html> ------------------------------ Message: 3 Date: Tue, 22 Dec 2020 11:48:02 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Another currying and lambda question Message-ID: <cafahfsvv7a1qnn0e_dqbl2t7qfmbg7c5jnopowpbcc9wuh_...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" In *Learn You... <http://learnyouahaskell.com/higher-order-functions> *I'm seeing this flipA :: (a -> b -> c) -> b -> a -> c flipA f x y = f y x and this flipB :: (a -> b -> c) -> b -> a -> c flipB f = \x y -> f y x What is it specifically about currying that makes flipA possible? Also, with flipB, could someone explain the beta reduction? It looks like f is not being acted on, just passed along, Would it look more like this in lambda calculus? (\x \y -> f y x) then (\x \y -> f y x) g a b gives g b a ? LB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20201222/bef1a243/attachment-0001.html> ------------------------------ Message: 4 Date: Tue, 22 Dec 2020 18:59:21 +0100 From: Francesco Ariis <fa...@ariis.it> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Another currying and lambda question Message-ID: <20201222175921.GA3626@extensa> Content-Type: text/plain; charset=utf-8 Il 22 dicembre 2020 alle 11:48 Lawrence Bottorff ha scritto: > flipA :: (a -> b -> c) -> b -> a -> c > flipA f x y = f y x > > What is it specifically about currying that makes flipA possible? I do not see how currying is involved here! Maybe when you pass a function to an higher order one? > flipB :: (a -> b -> c) -> b -> a -> c > flipB f = \x y -> f y x > > Also, with flipB, could someone explain the beta reduction? It looks > like f is not being acted on, just passed along, Would it look more > like this in lambda calculus? Indeed `f` is not being acted on (i.e. it is «outside» of the lambda) (λx. λy. f y x) b a (λy. f y b) a beta f a b beta fully expressed with lambdas would be: (λf. λx. λy. f y x) g b a ------------------------------ Message: 5 Date: Tue, 22 Dec 2020 15:15:42 -0600 From: Lawrence Bottorff <borg...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Another currying and lambda question Message-ID: <cafahfsuyrgcieajvo1c-ppqef+ayksjvbwopnwhejy9akdk...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Thanks again! On Tue, Dec 22, 2020 at 11:59 AM Francesco Ariis <fa...@ariis.it> wrote: > Il 22 dicembre 2020 alle 11:48 Lawrence Bottorff ha scritto: > > flipA :: (a -> b -> c) -> b -> a -> c > > flipA f x y = f y x > > > > What is it specifically about currying that makes flipA possible? > > I do not see how currying is involved here! Maybe when you pass > a function to an higher order one? > > > flipB :: (a -> b -> c) -> b -> a -> c > > flipB f = \x y -> f y x > > > > Also, with flipB, could someone explain the beta reduction? It looks > > like f is not being acted on, just passed along, Would it look more > > like this in lambda calculus? > > Indeed `f` is not being acted on (i.e. it is «outside» of the lambda) > > (λx. λy. f y x) b a > (λy. f y b) a beta > f a b beta > > fully expressed with lambdas would be: > > (λf. λx. λy. f y x) g b a > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20201222/e0b5c0f2/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 149, Issue 17 ******************************************