Source Code: github.com/tsoding/profun Waste Your Money: / tsoding
Жүктеу.....
Пікірлер: 51
@0xCAFEF00D6 жыл бұрын
I found this very helpful for understanding functional programming.
@zark47114 жыл бұрын
Juggling with indices is often tedious and might sometimes lead to off by one errors. If the board was a static 3x3, I would define a [[Cell]] containing all rows (horizontal, vertical, diagonal) and use functions like ‘all’ and ‘any’ to determine the winning and endgame states. For dynamic size boards this structure can be calculated by (assuming board :: [[Cell]]): let tBoard = transpose board in diagonal board : diagonal tBoard : (board ++ tBoard) where diagnonal ((x:_):rest)) = x : diagonal (map (drop 1) rest), diagonal _ = []. Again, if it was a static 3x3 board, I would just list all “rows” once.
@franeklubi5 жыл бұрын
Fuck man, this is all i needed, not some boring tutorial stating the basics, this
@florianfromm32656 жыл бұрын
Finally :) Just in for this great functional stuff ! Btw. would love to see Boids in Haskell (with Gloss :)).
@ferdinaldocoding6 ай бұрын
12:10 BIG LOL here 😂😂😂
@user-dn5ol9wc2u3 жыл бұрын
Чувак, от души спасибо за видео! Пишем с подругой сейчас игру "Морской бой" на haskell, и твое видео нам очень помогло. Ждем с нетерпением ждем следующих роликов! Dude, thanks for the video! We are now writing a game "Sea Battle" on haskell with a friend, and your video helped us a lot. We are looking forward to the next videos!
@leonardciupei80187 ай бұрын
Hello! I just finished making this game, it was my first ever experience building and running a program! Your video was super helpful and I learned a lot, not just about Haskell but also using Emacs. Thank you very much for this tutorial! :)
@samuraijosh1595
6 ай бұрын
Did you do this in haskell? Amazing!! I made a small hangman game in haskell recently. And OMG I loved it. Haskell makes it so that i can just take one look at a function and the function will speak for itself about what it's doing. Next try to build a snake game with haskell hehe.
@leonardciupei8018
3 ай бұрын
@@samuraijosh1595 Yes I did :) it was a really good experience with programming in general. I also did the Hangman game hehe. Right now I'm trying to develop a personal application through Haskell, wish me luck! P.S. I might try the snake in the future :)
@patrickdc6836 жыл бұрын
The logic in the playerwon function could be made a lot easier by pattern matching the 3x3 board.
@Tsoding
6 жыл бұрын
Sure! Feel free to submit a pull request with a fix: github.com/tsoding/profun :)
@zark47114 жыл бұрын
I would calculate the state running/ended, which player won or if it is a tie and whose player‘s move it is (assuming x always starts) from the board. This takes some (in this case little) computational power and trades it for more guaranteed consistency of the data structure.
@Antinumeric6 жыл бұрын
I feel like Gloss is doing a bit more heavy lifting compared to SDL in the C version.
@Tsoding
6 жыл бұрын
Yep, that's true. With gloss we don't have to organize the event loop as we did in the procedural example. But that actually enables us with making ~99% of the code pure functional. Notice how there is no a single `do` in the entire code base and the only place we use the `IO` type is in the `main` function. :)
@mehdisaffar4 жыл бұрын
This was amazing I loved it!
@stro32772 жыл бұрын
i just finished learning python.... this is like 20 steps above my paygrade
@mlady.y3 жыл бұрын
Thank you 😍, you help me a lot
@AlejoCP00 Жыл бұрын
Thanks for this video! It help me a lot 👌
@scottlim55973 жыл бұрын
excellent video. well done
@luisalejandrohernandezmaya2544 жыл бұрын
Excuse me. What is the double diagonal meaning at 11:21 ?
@electricimpulsetoprogramming Жыл бұрын
could you write an article talking the differences about each one of them and what you think. i get bored too easy by watching videos
@EmanAhmed-mg5vm2 жыл бұрын
how can i get the external modules to be added to the haskell file?
@Ahelhot4 жыл бұрын
Ok. but what about performance? if immutable structs copies data in memory after each call, how to draw assassin's creed in 60 fps?)
@neolight1010
2 жыл бұрын
I think Persistent Data Structures that solves that issue. But yeah, Haskell programs are not as fast as C or other low-level languages, but it gets pretty close.
@braydenmarshall8084 жыл бұрын
help-me-im-trapped-in-the-basement
@top_cat266 жыл бұрын
muy bueno , gracias¡¡¡
@zdeezy4206 жыл бұрын
This really cool I wanna know how big of a game can u make on Haskell? Like COD and fortnite?
@Tsoding
6 жыл бұрын
Not sure about COD, but Quake 3 is quite possible lambdacube3d.com/
@beauteetmusculation8191
3 жыл бұрын
@@Tsoding This lambdacube3d website and project is awesome. Such a shame this is not used anywhere. :-(
@scriptocreator
2 жыл бұрын
@@Tsoding _Oh, why did I, Russian guy, go to the Net…_
@funmath38352 жыл бұрын
so its better to follow haskell or is it good to c one
@anzo.p4 жыл бұрын
Beautiful
@madbad13103 жыл бұрын
Я ошибаюсь, или правильно чувствую русский акцент (хоть и не сильный)?
@AdamSchelenbergCom5 жыл бұрын
hack in Haskell every day.
@top_cat266 жыл бұрын
Please....web scraping in Haskell....Gracias...gracias
@tuckertcs Жыл бұрын
Where tf is part 1 lol
@Yetipfote4 жыл бұрын
fine. Now heavily parallelize it to 12 cores :))
@cepi248 ай бұрын
Sir, we are waiting for part 3, object-oriented version. Great job
@alexanderskusnov5119 Жыл бұрын
А где сравнение? Пустое видео.
@xiaoruchen64352 жыл бұрын
how do I run this on Mac?
@joe_hoeller_chicago4 жыл бұрын
Cabal is not installing
@Bratjuuc
3 жыл бұрын
Stack is better
@jacobscrackers984 жыл бұрын
At 13:10 the procedural and functional results don't look the same: the functional image has a border showing at the bottom and right side of the screen.
@alexanderskusnov5119 Жыл бұрын
very fast
@JohnnyRicha5 жыл бұрын
Would be great see an Object Oriented implementation.
@ruffianeo3418
3 жыл бұрын
but then REAL OOP - as in CLOS or Smalltalk :)
@jony17106 жыл бұрын
Nope, still don't understand Haskell. Much prefer the ML dialects. ;)
@Tsoding
6 жыл бұрын
Dude, same
@zerocoll203 жыл бұрын
Your skill is amazing but you have a bad taste for environment colors.
Пікірлер: 51
I found this very helpful for understanding functional programming.
Juggling with indices is often tedious and might sometimes lead to off by one errors. If the board was a static 3x3, I would define a [[Cell]] containing all rows (horizontal, vertical, diagonal) and use functions like ‘all’ and ‘any’ to determine the winning and endgame states. For dynamic size boards this structure can be calculated by (assuming board :: [[Cell]]): let tBoard = transpose board in diagonal board : diagonal tBoard : (board ++ tBoard) where diagnonal ((x:_):rest)) = x : diagonal (map (drop 1) rest), diagonal _ = []. Again, if it was a static 3x3 board, I would just list all “rows” once.
Fuck man, this is all i needed, not some boring tutorial stating the basics, this
Finally :) Just in for this great functional stuff ! Btw. would love to see Boids in Haskell (with Gloss :)).
12:10 BIG LOL here 😂😂😂
Чувак, от души спасибо за видео! Пишем с подругой сейчас игру "Морской бой" на haskell, и твое видео нам очень помогло. Ждем с нетерпением ждем следующих роликов! Dude, thanks for the video! We are now writing a game "Sea Battle" on haskell with a friend, and your video helped us a lot. We are looking forward to the next videos!
Hello! I just finished making this game, it was my first ever experience building and running a program! Your video was super helpful and I learned a lot, not just about Haskell but also using Emacs. Thank you very much for this tutorial! :)
@samuraijosh1595
6 ай бұрын
Did you do this in haskell? Amazing!! I made a small hangman game in haskell recently. And OMG I loved it. Haskell makes it so that i can just take one look at a function and the function will speak for itself about what it's doing. Next try to build a snake game with haskell hehe.
@leonardciupei8018
3 ай бұрын
@@samuraijosh1595 Yes I did :) it was a really good experience with programming in general. I also did the Hangman game hehe. Right now I'm trying to develop a personal application through Haskell, wish me luck! P.S. I might try the snake in the future :)
The logic in the playerwon function could be made a lot easier by pattern matching the 3x3 board.
@Tsoding
6 жыл бұрын
Sure! Feel free to submit a pull request with a fix: github.com/tsoding/profun :)
I would calculate the state running/ended, which player won or if it is a tie and whose player‘s move it is (assuming x always starts) from the board. This takes some (in this case little) computational power and trades it for more guaranteed consistency of the data structure.
I feel like Gloss is doing a bit more heavy lifting compared to SDL in the C version.
@Tsoding
6 жыл бұрын
Yep, that's true. With gloss we don't have to organize the event loop as we did in the procedural example. But that actually enables us with making ~99% of the code pure functional. Notice how there is no a single `do` in the entire code base and the only place we use the `IO` type is in the `main` function. :)
This was amazing I loved it!
i just finished learning python.... this is like 20 steps above my paygrade
Thank you 😍, you help me a lot
Thanks for this video! It help me a lot 👌
excellent video. well done
Excuse me. What is the double diagonal meaning at 11:21 ?
could you write an article talking the differences about each one of them and what you think. i get bored too easy by watching videos
how can i get the external modules to be added to the haskell file?
Ok. but what about performance? if immutable structs copies data in memory after each call, how to draw assassin's creed in 60 fps?)
@neolight1010
2 жыл бұрын
I think Persistent Data Structures that solves that issue. But yeah, Haskell programs are not as fast as C or other low-level languages, but it gets pretty close.
help-me-im-trapped-in-the-basement
muy bueno , gracias¡¡¡
This really cool I wanna know how big of a game can u make on Haskell? Like COD and fortnite?
@Tsoding
6 жыл бұрын
Not sure about COD, but Quake 3 is quite possible lambdacube3d.com/
@beauteetmusculation8191
3 жыл бұрын
@@Tsoding This lambdacube3d website and project is awesome. Such a shame this is not used anywhere. :-(
@scriptocreator
2 жыл бұрын
@@Tsoding _Oh, why did I, Russian guy, go to the Net…_
so its better to follow haskell or is it good to c one
Beautiful
Я ошибаюсь, или правильно чувствую русский акцент (хоть и не сильный)?
hack in Haskell every day.
Please....web scraping in Haskell....Gracias...gracias
Where tf is part 1 lol
fine. Now heavily parallelize it to 12 cores :))
Sir, we are waiting for part 3, object-oriented version. Great job
А где сравнение? Пустое видео.
how do I run this on Mac?
Cabal is not installing
@Bratjuuc
3 жыл бұрын
Stack is better
At 13:10 the procedural and functional results don't look the same: the functional image has a border showing at the bottom and right side of the screen.
very fast
Would be great see an Object Oriented implementation.
@ruffianeo3418
3 жыл бұрын
but then REAL OOP - as in CLOS or Smalltalk :)
Nope, still don't understand Haskell. Much prefer the ML dialects. ;)
@Tsoding
6 жыл бұрын
Dude, same
Your skill is amazing but you have a bad taste for environment colors.