All right, hello everyone, let's get started. My name is Kristina Devochka and I'm a software architect at admin control and I'm based in Oslo, Norway.  So if any of those topics lighten you up as well, I'd love to have a chat with you at any later point after this presentation. And I hope that with this session today, I can make you more aware about sustainability in tech and how it can be applied to Kubernetes. And I hope that I can inspire you a bit more to keep sustainability aspect in the back of your heads in your own projects. With this session, I would like to spread awareness about this topic across teams, organizations and tech community as a whole. But before we take a look at what actions you can take in order to improve sustainability of Kubernetes clusters and workloads that are running on those, let's take a look at the overall state of climate change and how tech is contributing to it. Climate change, is it overrated? This sounds like a clickbait title, a few of which you may find through the course of this presentation as my potentially not very funny attempt to capture your attention even more. But answering the question, we know one thing for sure that climate change is happening. And there is a lot of information out there in thousands of channels about the topics of climate change and sustainability. And even if we take a look at this year's agenda, we can see a multitude of sessions that are related to this topic. And even me standing here with this presentation today am part of the movement. But there is also a lot of misinformation out there which makes it challenging to separate facts from fiction. But we are all techies, we are technical people, we love facts, statistics, numbers, science. So let's take a look at a few facts that were taken from different research projects that have been done around the globe. We have been measuring temperatures on weather stations and ships from the mid-1800s. And we have been capturing surface temperatures with satellites and analyzing geologic data for the evidence of climate change. And since that time, all the data we have collected tells us one story, the earth is getting warmer. And based on all the data that has been collected throughout the years, there is almost 100% consensus among climate scientists that human activities are the main contributor to the climate change and increase in temperature. And the main driver behind increasing temperature is the greenhouse effect, which has been happening since the Industrial Revolution in the 1800s due to human manufacture expansion. And it is at its current point, the level of CO2 in the atmosphere has been at its highest of more than 37 billion tons. And during the climate Paris Agreement in 2015, 196 countries have agreed to do their best in order to avoid the temperature increase of more than 1.5 degrees Celsius to avoid the worst fallout of climate change. But as we all have good experience with estimating feature development, the same could be applied in this case as well because in reality, delivering on that agreement has proven to be more challenging than hoped for. And with currently implemented policies, we are looking at potential increase of temperature of more than three degrees Celsius, which is double as much as what was hoped for. And to me, this shows one important thing that every one of us in every industry by doing small or big action towards sustainability can contribute to the overall end result and towards our goal and agreements. But some of you, including my skeptical cat Penelope, may be wondering, but what does this all have to do with tech? Isn't technology a part of the solution? Is technology a climate friend or climate foe? And yes, technology will absolutely contribute to help mitigating climate change. And multiple research has shown that with help of digital technologies like cloud computing, Internet of Things, artificial intelligence and big data, we could help reduce emissions in multiple industries by as much as 20% by 2050. On one condition, we will be able to do that as long as those digital technologies are sustainable themselves and are being implemented, operated, and used in a sustainable manner. But the trend is clear. The need for digital technologies and the need for new data centers to host those services on is on the rise. And despite huge and important advancements and improvements in terms of energy efficiency of the hardware, cooling technology advancements and much higher focus on renewable energy, the higher demand in resource intensive services has also resulted in increased energy use, which at times can be challenging to fully cover with natural and renewable energy sources. And to me, this proves one thing. Once again, that each and every one of us should collaborate together in order to reduce the amount of unused and underutilized resources in order to reduce the total amount of energy and resource waste overall. Now, this has been a lot of science, a lot of scientific facts until now. So I would say let's cool down a bit and take a look at a few interesting facts of how tech can be contributing to climate change. And these facts, we may not think that much about. A quick quiz time. And we don't have much time overall, so I hope that you will not leave me hanging here and can just shout out the first thing you can come up with. This is the logo of OpenAI, the company behind products like chat GPT. And recently an interesting research came out where they have been measuring based on the amount of overall official data that we have at this point, they've been measuring the amount of emissions that have been produced by training a language model like GPT-3, which has been powering chat GPT during the year. And my question to you is, based on how much emissions it was estimated to be produced during training in one year, how many, the lifelong emissions of how many cars do you think it was estimated to be equal to? Any suggestions? That was not that big, but we are talking about lifelong emissions. But it's just the training. So it has been estimated to be producing during one year 502 tons of CO2, which was equal to the lifelong emissions of 109 cars, which was also estimated to be enough energy in order to power an average house in the United States for 120 years. And this is just the training of the language model where we have better control of how we, and when we are training it. But what I find is interesting is to see how we, as users of AI, of AI services like chat GPT, will be contributing to the overall amount of emissions that will be produced. For example, direct queries every day to chat GPT itself is estimated to be around 10 million queries. So now it has been quite a lot of lack of transparency and enough data to make really accurate estimations without avoiding speculation, but I'm really looking forward to see more data that will come from the authors behind these services. And the second and last question of today will of course be related to Kubernetes. There have been a bunch of research projects as well that have been looking into the amount of underutilized computer resources in Kubernetes clusters. On average in percent, how much underutilized computer resources it has been estimated to be for the Kubernetes clusters overall? Oh, not that bad. That was close. What was that, 34? Yeah, that was really close because it has been estimated to be more than 30% of underutilized computer resources that are running in Kubernetes clusters overall. And the same amount between 29 and 30% has also been a result of research for underutilized computer resources in physical and virtual servers. So it is clear that this is actually a quite small step that we can make which can help contribute to the overall goal of reducing the total amount of wasted resources. And really interesting report has been done from Cast AI where they have been looking and measuring the amount of underutilized resources of their customers that have been using this tool. And reduction in underutilized resources has been estimated to be like in 10 hundreds thousands of dollars. And at the same time you will also reduce the amount of unnecessary resources that are running out there and the cost you spare you could actually use in order to invest into more sustainability actions, sustainable related actions in your projects. So this I find to be a very interesting finding. So what this means of course is that there is always room for improvement and there are multiple actions that we can take in order to run our Kubernetes clusters and workloads on those more sustainably.  And we can take a bunch of different actions here in order to improve the sustainability of our resources and systems and the layered approach would be needed here. But it all starts with awareness. And still I don't hear sustainability being brought up that much during software development life cycle. And I need to say myself that for a long time I haven't been thinking about it that much myself. And once I started looking into ways to incorporate sustainability in my personal life I also started thinking about how it can be applied at work and in tech in general. And in one of the projects where I've been working we started to be challenged by our customers. We had governmental and public sector customers that started to be more proactive looking into the total amount of sustainability of their systems including the supply chain. And that's when the table started turning and the mindset started changing. First just a few of us at work started bringing up sustainability as an equally important criteria at different stages of software and platform development. But then more came up to speed. And we started bringing this up also in dialogues with our customers. And now with time sustainability has become an equally important part of the business and overall tech roadmap strategy. And the point is that it takes time and consistency to get there. But the correct mindset, talking about it, challenging other teams, our suppliers supply chain is where it all starts. And we hear a lot about shared responsibility model when it comes to adopting public cloud. But I think that the same could be really nicely applied to the topic of sustainability and Dread Hat has illustrated it really nicely on this diagram. And depending on where you're running your systems be it public cloud, private cloud, bare metal, or and depending on your position on your role in the organization you may have different level of control when it comes to implementing sustainability related actions of the infrastructure itself where you're running your resources. But most of us have enough power and control in order to look into what actions we can implement to make the resources that run on that infrastructure more sustainable like Kubernetes clusters, like our applications. So let's break it down a bit and take a look at some of the areas where it's worth to take some considerations related to sustainability. During software development at our work we need to take a lot of different decisions and many of those decisions are related to the supply chain. Starting from choosing a public cloud provider to choosing a data center service provider to bare metal servers or just choosing a new third party library or tool incorporating sustainability as an additional evaluation criteria can help you take more conscious decisions and contribute to the overall impact. And by supporting vendors and projects that are proactive in terms of doing what they can in order to be offering more sustainable services can also help us build more eco-friendly systems and contribute to reducing the overall negative impact on the planet. For example, when evaluating a new third party tool or library in addition to looking into the functionality take a look at how heavy the application is overall how much resources it requires in order to run especially at scale, how performant it is in term compared to its alternatives. When choosing evaluating a new data center or data center service provider take a look at what kind of data centers are being offered because depending on the type the resources may be utilized differently. Take a look at what energy sources are powering those data centers. Are they powered by 100% renewable energy or partially renewable energy? Take a look at what kind of cooling technologies are being used in order to process and maybe even reuse the excessive heat coming from the service which is an additional advantage. And there are even climate positive data centers that are becoming available for us like equal data center in Sweden which is actually reusing their excessive heat in order to power one of the cities in Sweden which is really exciting project in my opinion. So do check some of the resources I'm gonna share later to learn more about it. But of course it's important to stay critical due to the high level of carbon offsetting and greenwashing some of the vendor claims may not be 100% true in reality. So just staying critical and performing effect checking would also help you get a better picture. And another aspect here is where, in which regions you decide to provision your resources. Provisioning resources in closer proximity to the users will also not only reduce the network latency but also the travel length of the network packets. Looking at the heat map is even more interesting depending on the regions in different parts of the globe they may be powered with energy in a different way. And even if a data center is being powered by renewable energy and suddenly the weather conditions change or the demand on the data center grows they may end up in a situation where there is not enough of natural energy sources and renewable energy in order to cover that demand and vendors may be forced to switch to less sustainable energy sources like coal and other fossil fuels. So therefore a few tools are out there that can provide some visualization of the emission intensity of different regions. And some public cloud providers make it easier and provide you some of that overview. Some do not do that enough but there is also an open source tool which can help you get started which you can take a look at which is called cloud carbon footprint. And it measures the amount of carbon emissions of your workloads that are running in public cloud or on-prem. But what it also provides is a visualization of the different regions that public cloud providers offer and here you may see an overview of the Microsoft Azure regions and their emission intensity ranging from the ones that are low marked with light green to those that are more emission intensive with dark red. And from choosing where we are going to build our systems another important aspect to look at is what kind of nodes do we want our Kubernetes clusters to use and adjusting the choice of the node type and size that is as well adjusted to the needs of our application as possible is a tough journey where you may need to do multiple adjustments. And from my experience we have been adjusting the node type and size multiple times both in tests and production environments but having the tools that can help you measure how your application behaves over time how it utilizes the available resources a tool that can based on this data come up with some recommendations that can help you make a better choice and adjust can be really beneficial. And now some of the managed Kubernetes services are actually offering additional help where they can even make these choices for you or can provide this data without needing to install any additional tools. So this is definitely worth looking into and there are different VM types like computer optimized, memory optimized, burstable VMs which often are recommended if you don't need to use all of the CPU all the time or have sudden spikes in your application. Another point here is considering if you could use VMs that are powered by more power efficient processors that are based on ARM architecture which utilizes energy more efficiently per unit of operation. And apart from that also spot instances are often being mentioned but not only they're mainly being mentioned as a good choice for cost reduction but at the same time by choosing spot instances where it is applicable and brings value you also contribute to utilizing the unused resources that the cloud provider has to their max potential. So I have even seen a few stories recently from some of the companies that have been running on 100% spot instances on EKS in production and have been doing this for a while. So of course this is may not necessarily be a good use case for all the production environments but even starting with looking at such actions and dev and test environments who'd already take you a step further towards the goal. In some cases you may also have a possibility to implement for instance placement, proximity placement nodes. It's called a bit differently depending on what public cloud provider it is but in some cases if you have the region where data centers are spread far from each other across the region you could implement a proximity placement group which would ensure that the nodes where you provision your resources inside a single availability zone are placed in close physical proximity to each other which would also reduce both the latency and the travel length of the network packets. So the point here is to look into ways where you could use fewer compute resources but to their max potential. And from choosing which nodes you're gonna include in your Kubernetes clusters, looking into ways how we are scaling the nodes and our workloads that are running there could also help utilize the resources we have available to their full potential. And it's all about conscious scaling, scaling only what you need and when you need it. And this can be tightly coupled to the application architecture you have. I've seen projects where you might start with using monolithic applications and run them on Kubernetes but the challenge there is for instance it will be quite challenging to only scale parts of that application. And looking into ways you can improve your application architecture can also help you scale granularly and in a better way. And also thinking about manual or automatic scaling can also be beneficial.  But this is not the most sustainable action to take because that load may never come. And you may have those nodes running for many hours without actually doing anything useful. So looking into ways if you could incorporate auto scaling but at the same time remembering what is the max amount of instances you want the auto scaler to scale to. Because I've seen issues that have been happening with for instance bugs in the application like memory leaks or even the bugs on the vendor side which caused unexpected frequent scaling of many more resources that actually were needed. So putting that limit to avoid having many more resources provisioned is also beneficial. And probably the coolest thing that you can do in Kubernetes in terms of scaling is using event-driven scaling because you could adjust to how your application behaves and when it is most meaningful for that specific application to scale with help of event-driven scaling and tools like KEDA are super powerful. They have tons of scalers that are available for you where you could use different types of metrics and adjust them to the needs of your application in order to scale it when it is needed. Like we have also, we didn't benefit all our applications didn't benefit from the default metrics to scale so we were using custom metrics as well. And an example here can be for instance scaling on the amount of HTTP requests that are coming to a specific application. So definitely if you haven't used tools like KEDA check it out. And what I find super exciting is the carbon aware scaling that is really an emerging thing right now and during the keynote we have heard about it that KEDA is now coming with a carbon aware scaler and I've been really looking forward to it and I was expecting it to be announced today so that was really cool to see where you could use for instance tools like Kepler that was also mentioned by Red Hat too. For example gather the data of energy intensity of your workloads and then you could send the data and work with it in correlation with for instance the emission intensity of data centers or you could use the machine learning models to like make even more predictive scaling or more granular decisions in terms of scaling to scale and do more work when there is potentially less overall emissions that can be produced and also scaling in the regions where it is less emission intensity. And now we are coming to something that I briefly mentioned just now which is about the underutilized resources. Has anyone heard about scrim tests? Do you know what that is? A scrim test is when you remove a service and wait until someone screams and if someone screams then you need that service and you bring it back and if someone screams then that was okay and that service was never used and I'm joking I do not recommend doing that in production but this kind of illustrates a point which I could call in Norwegian something called Dugnod. In Norway once a year all of us gather around outside and start cleaning our gardens and our surroundings, our roads.  Not everyone meets up to that one and it's always a challenge every year but still doing the Dugnod of your own systems in a continuous manner it's not a one time action but monitoring continuously. If you have any resources that are not being used I've seen that there have been services which were provisioned at some point when it was needed but then it was forgotten and it was assumed that someone came up with the idea of cleaning it up but actually no one did. You can also have tools that could help you with cleaning that up. You could use the event-driven scalars like KEDA also to scale down to zero when it's not needed. You can look into ways of turning off some of the clusters if you do not need them during the night. That's what we found out that we could actually just start by turning off the clusters in tests during the night because we had seven hours during the day when they were not used at all in tests and with help of automation, infrastructure, as well you have that opportunity to reduce the amount of manual work and be able to turn off the resources that are not needed. And also thinking about when you are scheduling and running different types of workloads like if you have batch workloads that do not require to be run at a specific point in time or during the day, you may consider doing it later when there is less demand on the servers and on the regions. So looking into ways of continuously reducing the unused resources and scaling down when not needed is definitely a very simple and important change that you can make in order to reduce resource waste. And there are also tools once again that could help you with that and can alert you upon that and you can even let those tools do perform actions and clean it up for you if you dare. And the last point I would like to mention are the applications because without, we can do all we can in our Kubernetes clusters and workloads in order to reduce the amount of to run them more sustainably. But application, if the application itself is not efficient, if it's resource intensive it will still require a lot of resources and may not be using the resources in an efficient manner. So looking into how your applications are built with different things and also challenging the team's weaknesses if you have a different role. And there are some best practices for you like the best practices for any right applications and also the infotainment which provides recommendations on how you develop applications with the power of efficiency and resource efficiency. I'm going to go to the last part to show you that if you screen shots from one of our development situations where we have to use the power of efficiency or we take a look at some days of how all the resources are doing and here we have some information about estimating conditions and also an opportunity to use the regions and their conditions. And we could also get an information about over time how the conditions are and the resources all the time throughout those months so that we can get a better overall picture of how they are doing. And these are also features from cost management and cost which is built upon all the costs as well. In addition to publishing a cost the best plan is how to use the information like the patients don't trust it. And here you could also see like the amount of resources which can be requested versus what actually is built upon the price so that you can get a better impression like here it's possible. And then some of the recommendations that come through in terms of cost reduction can also be applied to sustain your costs. You have the right size of the cost you know to live or live in the way of removing the cost that are not needed. These same tools can actually be used as resource based. Here are some examples where you could base on the analysis of the time from the situation and in terms of how the utilization of the group which is based on this being applied. Or if you like resource utilization in terms of CDR and you can also analyze the nodes you have right now and how many of the conditions you need or this is more or less ordinary. So rounding up if you need to get started there is a bunch of resources that are available. But if all at least I see it that you need to go through kind of this test, you will need to define what you would like to measure in your project, what KPI is the kind of metrics you want to measure to get data and then you would need to do that all the time and then look at the history of all the state of the systems that are important. And how do we measure that out? I'm assuming it's because of the time. Yeah. It's my work time. It's good. Yeah, so if you check out a few of those resources that I mentioned here and I would also like to give you a shout out about the tiny environment sustainability and also open vehicles for how we can contribute to more sustainable choices even more. So check that out and it's all about balance. There is always a trade-off so you would just incorporate the sustainability as an additional factor. It should help you make the best, the better choice from the sustainability and you can make bigger than you think by just taking those small choices of your everyday by challenging your suppliers, by challenging your leadership thinking about investing time for you to make some of these sections of sustainability could help your project and our climate to improve and I would like to challenge you after this session to work perform a doing now in your clusters and your climate and our climate and if you'd like to talk about this more detail I'd love to talk about it. Thank you.


All of these social platforms that we have right now can be, if utilized correctly, an incredible positive tool to eliminate stigma. The more we talk about things, the more normal they become, right? And so I think, you know, that culture of sweeping things under the rug and not talking about sex or HIV or what it's like to be a young person or to be gay or transgender, all of that stuff, the more we normalize it, the more we just throw it out there for young people, for the world to see, the better off we will all be. With everything happening in this movement, this global movement of just everybody kind of collectively coming together, women, and saying no more, this acknowledgement of how wrong things have been and how men have been excused for a lot of bad behavior, but it's also shown us in that same place that there are so many men who are just as fed up as a lot of women are. There are a lot of men who are in full support of this, who wants this to change. I have had men come up to me and go, it's about time, and just so you know, I'm right behind you. We're not going to be able to change anything when it comes to female rights unless we have men understanding what we're asking for and acknowledging what we're asking for and giving us the respect to have what we're asking for. We have some of those guys that are right behind us, and then we have a lot of guys that we still have to bring over on our side. The work isn't done, but I think we should utilize the men that are behind us as much as we possibly can instead of isolating them. We need them to be part of this fight with us. I think that you guys are doing something incredible, and I think the power in what you guys are doing is creating an environment where you are talking about things that some people are still very scared to talk about. Even though South Africa is a country that has a constitution that is one of the best constitutions for our LGBTQ community, we still don't live by that constitution. What is written on that piece of paper and how people are actually behaving towards the LGBTQ community is not quite the same yet. It takes a group of young people like you to use a format like MTV that is for young people to do something that pushes the envelope and to make people out there, especially young people, not feel alone. The more you guys are playing these incredible characters, the more you're showing to South Africa and the world that this is the representation of our youth today, of our world today. So get with it, because young people are not going to stop. And I think it's so incredibly supportive and I think it's so inspiring. And so I am incredibly proud to be able to work with you guys. I think you guys are real true game changers and what you're doing is really going to change things. I want us to be able to take this space that we should have had a long time ago. I want African women to find their voice and to have a place where their voice actually lands and they're not just talking into the air and it's not heard. And I think those opportunities need to be thoughtfully created and handed over to young women. I think so often we forget that if you don't have those opportunities, there's nothing you can really do until you are given that opportunity. And I've experienced that myself in my own life. And so I'm a real believer in creating those opportunities for young women, especially, where they're not just getting an opportunity to talk, but they're getting an opportunity to talk and to be heard.  And I came out to my parents and they already knew, and I didn't have a difficult journey. I wish I'd have known at 15 or 16 or 17 that I was gay and that I could have known about sex and about relationships and about who I was at that point. I have two young boys and it's great that they have a daddy and a papa and they have no problem with that and it's just wonderful to be able to be who you are in this show. And I only wish I aimed for you because I wish I could have been gay when I was younger. I think sex should always be talked about.   And I think if more people were sexually educated at a younger age, it would be better for the whole world. A social media is so important for people to communicate with each other and talk to each other and kind of get a community going with each other. Her son, Prince Harry, the Duke of Sussex has inherited that brilliant capacity to make people feel loved and welcome.  And that was an incredible, incredible moment, a game changer, as I said, in the phase of AIDS and one that I think visually will never be forgotten.


Justice. Oh, I mean, that's not terribly obvious, sirs. I think it was the delivery of the box. Yeah, I mean, that's what I'm going by I'm not really reading it. I'm just reading.  It just melted that thing like it was nothing. I'm modified that gun too. Oh, what'd you do? Do it? If you look at it, it'll touch Like real speed Crit damage and So you added all this it didn't come with us. Yeah So magazine size crit rating energy and 20% damage 135% crit. Good God.  I really like the magazine size That that really makes it good one thing to be good, you know, just damage-wise, but the fact that you can Just hold down the button for all that time and just doesn't round the bullets. I think it was that shock thing We did a Huzzah I got so do I just have the hoverboard or do I have to do anything else? I Should tell you after this I think okay Yep, that's my wife brief. We start the stream with me yelling in the other room and then I just said let's just get on I Like, huh? Why? Why? A lot easier this way. Oh I got it. Yep. Yep. Yep. I see it Hoverboard yet Okay, so next quest says chopped in the screwed complete you might want to see what It's bound to There's a promise Q. Oh, you mean the hoverboard. I thought you're talking about the quest What's what the quest is bound to? Okay? All right, let me check It's probably I'm set because I had Q set to something else You know, there's called in it options. It's called like movement skill or something.  So I don't bound it That's what else might be our It's it's use purse switch Use personal vehicle. Yep. There it is Got it. So I'm not ready for the next one. I should do something else You're ready. Oh, I'm ready. Thanks for the bits guys. That was a lot of bits you guys threw at me for some jokes Appreciate that It is quite needed and appreciate it. Also if you need toothbrush, let me tell you something about quip Quip is an affordable stylized electric toothbrush perfect for travel or home use. I use one ask me why click on the purchase Click here to purchase click there That's a nice toothbrush. You can go in the about section and the panels you can see a picture of it get more information What is my phone doing in there? I'll be right back Why do I use a toothbrush? Thank you Because I don't want my ears to melt You're silly All right, I use a lot of mats there some stone and some wood Powerful sword and spears.  I still need stone Okay, so destroy the encampments Locate the active encampment.  I Can't I'm not very good at seeing people on the map I'm looking. Oh, there you are. There's like so much stuff on the screen, man. It's hard to It's one thing I always said about this game is just the screen is just full of all kinds of nonsense Are you playing outlander? I Got a goal when I'm gonna level up. I melted my other one down so I could hook this guy up Cut it out Why? Man, did they give out more mass than they used to or is it upgraded or something? Um, I have a slot that let you get ammo from them. Ah That explains all the swallowing do's And another one No, you can't holdy Noose I can't Who is throwing stuff at me you good guy.  I don't want anymore. Is there a doll on me or something?  Sup Ty we pitch you can do a Bob a doobie beep a doobie doobie Okay, I gotta find you guys now Dabba dee beep. So we got four out of five encampments Attend to the survivor There another cake quest. Oh Yes, I wasn't done or maybe that was somebody else's cake quest There's a cake quest shared No, okay, I thought I was finished. Yes. I wasn't It said you're a five out of five. Yeah I meant it earlier, but the button was way over there. I got to change that 789 the XQC This guy's about to die again. I'm gonna change my buttons real quick So sweet. It's Z Q Z X See ZX what See see okay That's what I did ZXC That is so much easier Although I just wasting the ability hidden it. Oh this guy's dead over here. Did he just did he DC? I don't see him in the list anymore.  You have to hold it I said Q Wait, I will double-check. We have to hold down a long time we Doggy oh Can't run them over with it No And if you get hit by like that smoke or anything like that or a bone you get Well, just shot you in the back of the head again, I will attend to the survivor a med bar what this That's any freaky in the deuce Did you just do to this man? Okay, that's the thing That's the thing I had no idea He just left. I know right my people need me We did it over this way is a by me is a chest Chest is it a mimic? I got duct tape. You can't rush that extraction No, wow, so you just got to sit here Yeah, you're far max or whatever Kill some farming math There's a chest down here. Wait if I loot the chest you don't get to loot it or is it per person? So as per person nope, it's just to you I Feel like a loop goblin So I just snagged that up right in front that guy Did he did you have it first? No, I had it first Okay, I Still feel bad though. I've had people where it's like a tier six chest and they will See me Getting it and then they will shoot it and kill Or they'll just like destroy it So nobody gets it Yeah, this hoverboard has been the game for a long time So if the people want to save Warframe ripped it off, they probably could say it doesn't mean it's true But but this hoverboard has been a game a while. I Remember when the first came out I want to play and I thought I was like I keep getting sick Let me show you the secret like Well anyway So, let me show you the secret place. Oh secret place Well song requests aren't on GD So the bot just purged you a lot of gift boxes everywhere. I've been You can pick those up after I'm not as fast as you I think I lost you did you go this other year? Oh I almost jumped off the cliff. Oh that gun's just like I Taught him a lesson.  They're hitting the button Everybody's showing some love in the chat. Thank you so much for the support man 34 months That's a long time sir. There's a way to see my dailies from this screen. I wish that would make way too much sense I'm gonna um Well, I guess I'm not Okay, this guy's just box being yeah, he's trying to be a troll Now he's let me out I was gonna go to these gift boxes. See if I can round them up before the time runs out Probably nothing that good in them. Anyway There is Can you loot while you're on this thing or you have to get off? Gotta get off It's kind of weird to control Wow, thanks for the bricks People work hard for this break.  I'm not gonna mess with that. All right. Let me see if I can upgrade something skills building repair speed The anti-Newtonian slot and Gadgeteers Okay Don't think I care about that too much yet Shotgun Unlock three stars shotgun evolution Increases trap damage ability damage gadget damage and healing dumper. Yeah, I'm doing that purchase party offense Defender slide, I don't care about the fender slots. I Think the top row is the soldier Yeah, probably is So I was working on the middle which was outlander At least I think it was outlander. I don't know.  Well, you immediately say garbage. I believe that Training team slot for the two


All right, let's get started, hey? Hello? My name is Tony Morris. I'm going to talk to you today about list folds. It's a beginner level talk. I'm hoping to transfer some knowledge to you to think about list folds so that you can really understand how they work. Who was at the intro workshop yesterday? Oh, that's nearly half the people. We did list folds yesterday. And for the other half of you, we're going to do it again. OK? A bit of a different format. All right. So this is where I'm from, Brisbane, Australia. I don't actually live on the river, but it's in the state of Queensland on the east coast of Australia. That state is currently on fire at the moment. If you've looked at the news, there's fires all up and down. It's very smoky. Had to fly an airplane through it the other day. Couldn't see. That's OK. If you come and visit me, I'll show you around. That's the east coast of Brisbane. Pacific Ocean just off there to the left. I work at the Queensland Functional Programming Lab. So that's a team of seven or eight people. And we're sponsored by the federal government and the state government to do functional programming. Yeah. So we need to talk to the Indian government. So we write Haskell most of the time. Our team. We're a team of programmers. And we use a lot of languages, but mostly Haskell. And we work under what's called the CSIRA. It's the Commonwealth Scientific Research Organization. OK, so what's the goals for today? Who's heard of left and right folds on lists? And for those of you who have your hand up, what is that the end of your knowledge? That's it. You've just heard of it. You've heard of it, but that's it. A few people. My goal today is to transfer you some knowledge so that you can understand internally what they do. I get a lot of questions about them in my email. Can you tell me when to use the right one? What does this one do? What does that one do? How do I think about them? I want to answer these questions. So first, we have to talk about what exactly is a list. What is a list? A list is either nil, an empty list, that carries no information. It's just an empty list. Or it has one element and then another list. Think about lists this way. I can make any list this way. Using either nil or cons. Nil being empty list, cons having one element and then another list. It's never anything else. It's always nil or cons. So this is the Haskell signature for them. So we say that nil is just a list of elements A. It's the empty list. And cons takes an A, the first element, and then a list, the rest of the list, and it makes a new list. OK? The word cons, by the way, goes back to the 1950s. So we tend not to make up new words when they're that well-established. Here is the Haskell source code. What this says is we're declaring a data type called list, carrying elements of type A. It's made with nil, that has nothing, or with cons that has an A and another list of A. How can we make lists using this? For example, here is a list that has one element, the number 12. I've called cons. I've passed in one element, 12, and then the rest of the list, nil. There is no rest of the list. What about the list ABC? I call cons. I pass in the letter A, and I have to pass in another list. So then I call cons, and then the letter B needs to pass in another list, cons, c, nil. I can make any list using cons and nil. OK? That's the definition of a list, or a cons list, as they're sometimes called. Sometimes, if you type into Google right now, you might see nil's spelt square brackets. Just so you know, if you ever come across that, it's the same thing. And sometimes you'll see cons as just a colon, or sometimes a double colon, depending on the language or whatever. So here's the list, one, two, three. One, cons, then a whole new list. Two, cons, and then a whole new list. Three, cons, and then nil. This is the definition of a list and how we make them. OK? So when we talk about folds, we're talking about these kinds of lists. Footnote, there are languages for which this is not true. They talk about other kinds of lists. But if you just think about, like if we consider C sharp, for example, that has an aggregate function, which is a kind of fold, but it works on other kinds of lists, so it's not really a fold. So I'm gonna just talk about it in terms of cons lists. So you've probably heard of, yet?  You've heard of left and right folds. You've heard of them, that's it. Walking down the street one day, and someone said left and right folds, and then you just kept walking. Right? In Haskell, they're called fold iron fold L. Scala, they're called fold right and fold left. And C sharp has this function called aggregate, which is essentially a fold left, kind of. So just to be clear on our goals. When do I know to use a fold? What problem do I have so that I'm gonna use a fold? Which one am I gonna use? And finally, what do they do? What is a good way to think about what they do? You might have seen these fold diagrams that are on the internet. They're pretty good diagrams. They're quite accurate. They don't really help, I think, in my experience.  And I show them this diagram, and they go, I still don't know what a right fold does. It needs some explanation. This is the left fold diagram. Didn't help. And sometimes you've probably heard of this. A right fold does folding from the right and a left fold from the left. Not only is it not helpful, it's not even true. So I've also heard this. We're gonna use the right fold when we need to work with an infinite list. This is not correct, okay? So sometimes they're just not right. So, we're looking for an intuition that doesn't require to already have an expert knowledge that is satisfactory, that you feel like you've understood something and it's not wrong. If you've ever read a monitor tutorial on the internet, you'll find that they meet the first two goals. Like, consider burritos. You don't need a deep understanding of burritos. Burritos are satisfactory. But monads are not burritos. Sorry, they're not. So I'm hoping to achieve all three of these. In practice, or the way to think about these two different functions is very different, okay? The way the intuition for each of them is quite different. So I'm going to try to talk about them each differently. So let's talk about what fold L does, fold left. It takes three values. Okay? It takes a function F, B to the element type to B. It takes another element B, and then it takes the list that we're doing the fold on. I also write the C-sharp type signature there if you prefer to read that, I do not. How does it take these three values to return a value? It does this loop, okay? So everyone's heard of a loop, right? They taught that back at loop school. I remember first year undergrad, loop school. So if we look at this loop, who's written a loop like that before? Everyone's written a loop like something like that. And importantly, these are the three components of the loop that we get to change with fold left, okay? We get to pass in a function, what to do on each iteration of the loop. So that's the B to A to B, that thing there, the F. The Z there is the B, so that's what the value to start the loop at. And finally, the list, the thing that we're looping on, or fold lefting on. So let's look at some real code. Let's add up the numbers in a list. Here's a list of numbers, add them up. Okay, what am I gonna replace Z with? Well, zero, yeah? What about F? Plus, you were listening yesterday, excellent. That will add up the numbers in the list. Left fold, giving the accumulator through the loop, R, the element A, add them, start the loop at zero, do it on the list. This will add up the numbers in a list. And if you ever reduce that expression there, you end up with just plus. Just do plus on each iteration of the loop. What about multiplication? What do we replace F with, the function? What are we gonna do on each iteration of the loop? We're gonna do multiplication. What are we gonna start the loop at? One, we had that debate yesterday. Some people say zero. It's gonna happen if I put zero there. Zero, yeah. One is the identity for multiplication. One is the thing that does nothing to multiplication. Like, one times X gives me X, it did nothing to X. Okay, there it is. It's gonna multiply the numbers in a list. And there's the code. This is real Haskell code. How to multiply all the numbers in a list. Left fold, spin on each part of the loop with multiplication, start at one. Fold left as a loop. I mean, if you open up the source code to fold left, you won't see a loop there. You'll see all sorts of crazy recursion and then you'll see a sec or something like that to make it faster. But all you need to think about is it does a loop, that loop. How do you reverse a list? This was a trick question yesterday. So I taught everyone about fold right and then I said, okay, now reverse a list. And they tried to do it using fold right. And it ended up very slow. Let's do it with a left fold. What am I gonna replace Z with if I'm gonna reverse that list? Nill, the empty list. And on each iteration of that loop, I'm going to take that element and put it on the front of that list. That will reverse the list. Left fold through the list, pull the elements off the front and put them on the front of a new list, Nill. It'll come back reversed in linear time. There it is. I have a function. There's the list being accumulated R. There's the element off the list. Cons it. Do that in each iteration of the loop, start at Nill. This will reverse a list. That's the real code. Actually, yeah, I told a bit of a story yesterday. I once went for a job interview about 15 years ago. No, maybe longer 20 years ago. And the interviewer said to me, reverse a list. And I said, okay, what language? It was actually a C-sharp job. And then the guy said, you know, any language you prefer. I said, okay, fold left, flip cons Nill. And I didn't get the job. So I don't recommend you answer that in that way. But it is correct. That will reverse a list. What about the length of a list? What are we going to do? We're going to start the loop at zero. And for each of the accumulating value R, we're going to ignore the element A and just add one to R. That will compute the length of a list. So the function plus one, given R, ignore A to R plus one. Do that on each spin of that loop and we'll add up the numbers in R. Sorry, it'll compute the length of a list. There's the code. I essentially read this word here as do a loop. That's how I like to think of it. On each iteration of the loop, do that, start there. That will compute the length of a list. This is just a point free way of writing that same function. Const means ignore the element and then do plus one on each iteration.  They're exactly this loop. That is to say, I don't need a little footnote here to say just kidding, it's not quite precise. It is exactly that loop. Which means that any question we might ask about a left fold, we can also ask about that loop and we'll get the same answer. For example, will that loop ever work on an infinite list? Nope. An infinite list, by the way, is one that doesn't have nil. It's just cons all the way to infinity. If I put that into a left fold or into that loop, it just will never give me an answer. It'll sit there and heat up the world a bit more, set Queensland on fire a bit more. It's easy to transfer this information because you've probably already heard of loops. I've used your existing knowledge to transfer this information. Left fold is a loop. For right folds, there is no existing thing that I can use to transfer the information. You just simply need to commit to the definition of a list, which is nil or cons. So let's commit to that right now. That's what a list is. Folding to the left is a loop. The fold right function. Well, it takes a function A to B to B. Then it takes a B, so A is the element type in the list and it takes a list and it returns a B. There it is written in Haskell. There it is written in, actually that's Java, I think. I don't know. One of those languages. What does it do? How does it take that function, that B, and that list and give me a B? It performs constructor replacement. So constructors, remember, are nil and cons. They are the two things that construct lists. The expression fold right with the function FZ on a list. We'll go through that list in no particular order and replace every cons with F and nil with Z. If it sees a nil, which it might not because it might be infinite. So if we take this list A, B, C, D, and I fold right with FZ on that list, I'll get back whatever value is replacing cons with F and nil with Z. Whatever that is. So if we consider this is like a list of numbers, A, B, C, and D are all numbers and I wanted to add them up. I can replace F with plus and Z with zero and I will add them all up. So that's another way of adding up the numbers in a list or multiply, let's multiply them. So here's a list of numbers, 4567. I'm gonna replace cons with multiplication and nil with one. Now that will multiply the numbers in a list. Fold right did construct a replacement. The important thing about fold right to recognize is it doesn't do it in any particular order. There is an associativity order but there is not an execution order. So that is to say some people might say to me, fold right starts at the right side of the list. This can't be true because I'm gonna pass in an infinite list which doesn't have a right side and I'm going to get an answer. If it started at the right, it went a really long way and it's still going. So that's what I should see if that statement is true but I don't see that. It associates to the right. It didn't start executing from the right. It's a subtle difference. What if I have a list of booleans and I wanna add them all up? What am I going to replace nil with? Not 99. So I have this list. It's true, cons, true, cons, false, cons, true and I replace nil with true and cons with and like this. It will and them all up. So there's the code. Right fold replacing cons with and and nil with true. It doesn't do it in any order. I could have an infinite list of booleans. Suppose I had an infinite list of booleans and it started at false, cons, false, something and I said, fold right and true. I should get that false and I do. So clearly it didn't start from the right. It never went there. It just saw the false and stopped. How about appending two lists? Here's a list and here's a list. I don't want to append them. Do you agree with me that I'm going to go through this list and replace cons with cons and nil with that list? Who agrees with me on that? That's how you append two lists. Question? Oh, I agree. Oh, you agree, okay. It's just an intuition for thinking about appending two lists. I take the first list, I'm replacing cons with cons and nil with the other lists. They're now appended. So now that you know that, you should not be afraid when you see the code to append two lists. Here they are, list one and list two. I'm going to go through these lists here and replace cons with cons, that is to say, leave it alone and I'm gonna pick up this entire list two and smash it straight over the nil. And that will be appended. Cons with cons and nil with list two. So here is the code. Go in list one, replace cons with cons and nil with list two. This will append list one and list two. Sometimes I show people this code and they get scared. Whoa, hang on, what's going on here? I'm used to loops and things, that's how you append lists. Or go to the pointer at the end and update it to the other list or something crazy like that. But if you get an intuition for fold right, which is doing constructor replacement, it's pretty straightforward, right? Cons with cons and nil with list two. Of course it's going to append the two lists. This is just a point free form. You might choose to say that at your next job interview. Hey man, append two lists, okay. Flip fold right cons. Tell me how it goes. What about mapping a function on a list? So who's heard of the map function? Well who's never heard of it? How about that? Who's never heard of the map function? Everyone's heard of the map function. We have a list and for each of the elements I want to run a function on that element to make a new list. Like I might have a list of numbers and I want to add 10 to all of the numbers. I want to map plus 10 on that list. So here's my list. Cons a, cons b, cons c, et cetera, et cetera. What do I want to replace cons with? Given the function f, do you agree that I want to say cons f of a, cons f of b, cons f of c and d and then nil. That's what map does. I want to replace cons with f and then cons and nil with nil. So given x, I want to call f then cons and nil with nil. This will map a function on a list, the function f. So there's the code. It's not that scary now is it? That's how you map a function on a list. We replace cons with this function and nil with nil. We have mapped the function on the list. Once I had to write mapping a function on a list in Java, this was a long time ago, 15 years ago, I didn't use fold write. This is just like footnote caution. If you use fold write in Java, what's going to happen? Say it loudly. Stack overflow. Yeah, this fold write is recursive. For every element in the list, it's building up a stack frame. So you can imagine my disappointment when I called fold write on the JVM with a list of like 10,000 numbers or whatever it was and it just said stack overflow, have a nice day. Because the JVM I used to use a long time ago was the IBM JVM. It did tackle optimization, but it didn't optimize this one. It wasn't in tail position. So yeah, I had to use a loop and it didn't work on infinite lists either. Had to make it a heap list. So I'm just letting you know that all of this sounds great, but if you run out the door right now and said, oh, I'm going to do it in Java, caution. Same is true for Python and C-sharp. I've tried it. Stack overflow. What came up yesterday was this little operator here. Function composition. Function composition is take two functions and glue them together and make a new function. So I'll give you a bit of an intuition for dot, for function composition. I read it from right to left. Call F and then call cons. So wherever we are in the list, somewhere in the cons cell, which means it has an element right next to it. Call F on that element and then do cons and replace nil with nil. Wonder what would happen if you said that in a job interview. I should try that. Someone will say, map a function on a list and they're waiting for me to say for loop. Okay, no, fold right. What about flattening a list of lists? So we have a list and each element is itself a list and we want to flatten it down. What am I going to replace cons with? Any ideas? Append. The function we just wrote. Go through each cons and replace it with the function that appends to lists and nil with nil. That will flatten the list of lists. Cons with append and nil with nil. We leave the nil alone. There's the code. Fold right, append, nil. Fold right does construct a replacement. Okay, filter's a little bit ugly. You know, who's never heard of the filter function? Never heard of it. Everyone's heard of it. We're talking about it outside right now. That's how, okay, all right, filter. We're gonna take a predicate and keep the elements that match that predicate. That's a bit tricky. What are we gonna replace cons with? We wanna take the head at that cons, the A or the B or the C or whatever. And we wanna check if it matches a predicate. And if it does, we're gonna cons that value back on again. But if it doesn't, we're just gonna leave it off. And then move on to the next cons cell. So we wanna say, given the element that I'm visiting, x. If it matches the predicate, then cons x. Otherwise, do nothing. ID, the identity function. And replace nil with nil. So if you ever see this code, you'll know that it's filtering a list. Replace cons with this and nil with nil. I happen to have a particular aversion to the if-then-else construct, by the way. I wish it would die. It takes three arguments for a start, right? This one, this one, and this one. And for those of you who attended yesterday, what are my favorite functions? How many arguments do they take? One. So I don't like that one. There is a function that does if-then-else that does take one argument. It's called bool. I've used it here. And it does if-then-else with the arguments around the right way. There is a right way. It says, if this, then this, else that. That takes one argument. The reason I like that function is because I can get down to that point there. And that point means I don't have to name as many identifiers. That's just my goal in life. It's not really the point. The point is that I can do that. I can look at this code and I can say, replace cons with this and nil with that. What is it going to do? It's going to filter the list on P, okay? I find this one quite interesting. So what this function does, is it takes an element A and a list of A and it returns the first element out of the list. It's the first element. But it could be nil. And if it's nil, return the other element that I passed in as an argument. Okay, so if this list is nil, return that. Otherwise, return the first element. What am I going to replace cons with? Any ideas? Const. Const the first argument. I agree. And nil, that value there. That's the thing that we're returning if nil, right? So given an entire list, if you ever see nil return that value, but if you see cons, then return the value that's sitting right at the head of that cons. That'll do exactly what our requirement is for this function. So given this list, I want to return A. That's the first element of that list. Here is a function that, given the A, and then the rest of the stuff after the cons, just return A. Replace cons with that. And replace nil with that default value that came in as an argument. That will do what it is we need to do. So there's the code. Who remembers writing head or yesterday in the workshop? We wrote head or, right? This is head or. And we did it with pattern matching and all of that. We could have just written this. Fold right, const or constant with that argument. Who remembers this function? Who's never seen this function in their life? One brave person at the back, a few people. We had quite a discussion about this function yesterday because this function gets rewritten over and over and over again in its different formats. How much time do I have? I'll show you an example. Who's written this kind of code? Go through a list. If you see null return null. If you don't return a list of values. Who's written this? Half of you are honest. And the other half are currently writing it right now. It is of this form. Given a list of maybe null a's, return a maybe null list of a's. It is of that structure. Who's written this? Go through a list and for each of those elements go through another list and run some function at the end. What have we done here? Oh, we just joined it all back up to a new list. Compute the Cartesian product. I've written that function. It is of the same form. Given a list of list of a's make a list of list of a's. It is of that same form. Here's another one. Who's written this function? I have. We all have. Go through a list of things that have apply and apply them all to one single value. For example, 99 and collect all the results. It is of the same form again. The form is given a list that takes x to a, a function, and returns a function x to list of a, and puts x through all of those functions and gets all the a's and collects them in a list. Those three bits of code looked like all different bits of code, right? But actually they're all the same bit of code. They're all this function. This function's often called sequence. If you ever come across it. I'm gonna write sequence using fold write. What do I wanna replace cons with? Here are all my f of a's. That's an f of a, that's an f of a, that's an f of a, that's an f of a. What am I replacing cons and nil with? It's pretty close. It's pretty close. It's also very close, yeah. You might even be right. Like you probably have the correct code in your head. It's just that you didn't say it. Yeah. So given a, which is the f of a, and b, which is the rest of the list after the cons, run flat map, as you said. This is what this code does. Run flat map x, flat map b to y. Cons x and y, and lift it all back out again. I'm gonna replace cons with that function. And nil with, so the nil needs to be an f of list, right? Because remember we're returning an f of list.  Return means the neutral, the neutral effect. Okay, don't do anything. Just do something with nil. So here's the code. Replace cons with this thing. So put lift to cons all the way through there. So to sequence a list, we fold right replacing cons with lift to cons. And nil with return nil. If you find, I chose to give you this example because it's hard to communicate. But if you wanted to figure out why this works, you wanted to just sit down and figure it out, you would get a pen and a paper and you'd say, right, what am I replacing cons with? Exactly. Well, with that function, then we have to figure out what that function does. And when you've figured it all out, you'd find it does sequence. It does all of those things that I just showed you with loops. FoldR may work on an infinite list. So if I had the list from zero to infinity, and I said, call that head or function back here, where is it? This one. So here's a list to infinity, zero to infinity. And I said, okay, passing some number here like four. I should get back zero, right? Because that's the first element of the list, zero to infinity. Okay. You wanna see some code? This is an infinite list of ones. You might not believe me. In which case, do you believe me now? Fold right, const. So take, that's it. Okay. Head or 99 infinity. This will not go all the way to the right of that list. Because when it gets there, there's just one cons, it's all the way. And so I should get one, and I do. So fold right just worked on an infinite list. What's the complexity? Of head or, it's O, O, O one. Right, is that what you said? Head or should be O one. So whether or not fold right will work on an infinite list depends on the strictness of the function that we're replacing cons with. Okay, so const, the function I just used, is lazy. It ignores the second argument. And therefore it works on an infinite list. It only replaces nil if nil ever comes to exist. It doesn't exist in infinity. How about this function? Fold R cons nil. Leave the list alone. Replace cons with cons nil with nil. It does nothing to the list. It's an identity function. What's the identity function? Oh, what's the function that gives me an identity for bool? It's an interesting question. I just showed it to you. I'll let you think about that. So the key intuition is the thing to take away is a left fold does a loop and a right fold does construct a replacement. If you always remember those two things, you'll never go wrong. Left fold will never work on an infinite list. We can see that in the loop. Right folds might. And these are just independent observations. They've got nothing to do with programming languages. I've used Haskell as the example. But these are just independent things of the programming language. So we could solve all of these problems as we just did. I just want to be very, very clear on this. Fold left does a loop. Fold right does construct a replacement. And there are no footnotes required. This is precise. Okay.  It didn't this time. Yes, it did. It always will. Okay. There's no footnotes required. Thanks. We've got time for a quick question or two. Cool. Hang just wait for the mic there. Yeah. The example that you had for sequence, right? Yep. Where you had a list of side effects. If you could go back to the slide. Sure. Yes. So you're applying A first and then you're calling it on B as well. Does that mean, would that work on an infinite list of side effects or if I just wanted to apply the first N side effects is that going to stop at N or is it going to completely traverse the list? It's a really good question. I don't know if I've got time to write the code but I'll just give you the answer. The answer is yes it will work on an infinite list and I'll give you the example. Suppose I had an infinite list of maybe values. Okay. Or so the nullable kind of value and we wanted to sequence them. And if we remember what it does, if it ever sees the empty or the null case then it just stops right away and returns null. So you can imagine that I had a not null value. Say let's say five of those and then a null value and then an infinite not null values. It should give me back null and it does. So yes it does do that. It will work on an infinite list.  We'll do that. But yes it will, okay? Yeah, so it's easy to find out that where we should apply for lift because it's whenever we solve C loop or so we will apply the for lift but my question is how to get the intuition then when we should apply for right. For example, the examples you have given for for right it is append filter. So these methods are already there. We don't have to do for right for that. We can go and use filter and all these things append length of a list. So when should we apply for right? Means in real application. Yeah, it's a really good question because here's the best I can do which is to give you the red flags. Like I was trying to be precise so I didn't wanna give you the red flags because they're not quite precise. So let's talk about the length function and what's the length of the infinite list? And the answer to that is it doesn't fit inside integer and so we immediately suspect that maybe we should use a left fold, okay? And it turns out that yes we do. That won't always work. On the other hand let's append two lists. Suppose I had the list from infinity and I appended that to infinity then I said what's the first element? I should get an answer and so we're probably not going to use fold left in that case. So these are just red flags but they're not precise, okay? Does that help? I could write a different length function that doesn't return int. It returns something else, another data type into which infinity does fit and then I would use a fold right, okay? So you have to sort of pull all these details apart. Look at the red flags and figure it out from there. I can't give you, I can't think of anything that is very precise. It depends on strictness and I'd have to write big paragraphs and things. We can talk about it though more afterwards if you like. Yeah. I mentioned that fold left generally doesn't work or it doesn't work on infinite lists. That's right. But the function that we are passing, if we add that additional logic there, for example a take function which essentially takes an element and then a map on that or something like that. Do you mean like take the first few elements? Take first and apply F, right? Yeah. So why can't we use fold left there? It's essentially an implementation. To write take, you know? Yeah, a map and a take. So I'm gonna write the take function. Yeah. Yeah, I'm gonna use a left fold. If take, except an int. Right. So that's an infinite, I can do that on infinite list as well. Actually, yeah, no, sorry. I'm not gonna use a left fold. Yeah, I'm gonna use a right fold there. Yeah. But I'm gonna want strictness. Yeah. So the function, the natural support is with right but what I'm saying is we can have guards on the fold left function that we pass to maybe support take on left fold itself. So. For example, if the fold left says take 10 or int 10. Yeah. But so we're not gonna use fold left to implement that function. But I'm saying is we can. Oh, we can. Can we? The f that you're passing that should have that check in this case that you don't call the function anymore. Since it's stale recursive, you just. I don't think that'll work. I don't think you can write take just with a raw fold left. You'd have to do a few tricks. Yes. Yeah. We have to essentially not, it will not be a raw fold left. Yeah. Right. Okay. So the point you wanted to make was that it's a natural support for an infinite list or a stream list is, you should always fall back to fold rate. Yes. But fold left, it's not that it's not supported. You'd have to do a bit of tinkering with the function that you're applying. That's right. Yes. To do take, yeah. The take function is quite quirky actually. Yeah. There's one more there. So during the talk, I noted down this question and it's like, suppose we are finite list, not an infinite list. So in that case, why would I ever use a fold left when I have a simple loop? Or in general, like if I generalize this question, why are like loops forbidden in functional programming? Oh, why? Okay. I'll answer the second question and hopefully that'll answer your first question. Okay. Okay, so why are loops not allowed in functional programming? It's a really good question. Let's have a look at a loop. They're all the way back here, right? Got a way to go. Where was it? Geez, I got a long way to go. There's a loop. Why are loops not allowed in functional programming? By the definition of functional programming, anything that appears on the right side of equals, I can substitute with what's on the left. Okay, that's the definition of functional programming. And therefore, if I take say this loop here and I've said r equals zero, I can now go through this loop and substitute every time I see r with zero and the program should not change. But clearly it does. Okay, so if I replace r with zero here, this is a different program. And so it violates the rules of functional programming. So that's why I can't have loops in functional programming. And that's why we resort to four left and all right? Pardon? And that is the reason why we resort to things like four left? Yeah, well, it's a consequence of resorting to things like fold left. But you might say something like, the reason we use fold left is because all of the loops have been refactored so that all the differences are out as function arguments. And so then we're just gonna use fold left. Okay, and are there some performance differences also? Like for the similar list, small list, if I use four left versus if I use while loop, conceptually I understand, but is there some performance difference also? If you use a fold left versus a loop. Yeah, it's simply counting. It depends on the language, right? So there is no loop in Haskell. So there's nothing to compare to. But if you go and use say Java, then yeah, because you're gonna build up stack frames unless you do a tackle optimization. It depends on all of these kinds of questions. Yeah, okay, cool. All right, I think we're out of time. Thanks guys. Talk outside, do you like?


Test, test. Welcome everyone in this new video, I hope you're doing great, happy new year, all my best wishes for 2023. Speaking of 2023, I can't wait to get the F1 season to start again, the winter break is great but I miss watching races. Today, what to expect in 2023? I've put four points on my board, please if you have any more points or things that you expect in 2023, leave them as a comment, I'll read them and there's gonna be more video coming up very soon about 2023 but for now, those are my four points of 2023 and what to expect. So first one Mercedes, Ferrari and Red Bull. Yes, I see Mercedes coming back into the title fight while I see Red Bull staying on top even though they've got less winter than anyone else because of their position and championship as well as their penalty for breaching the cost cap. I think Ferrari is gonna have a strong car game and I think Mercedes is gonna be up there with them so that is actually that's the thing I'm the most looking forward to is seeing those three top things every weekend fighting for pole position and wins. If we get that, we're gonna be jumping on a sofa like crazy because there's gonna be some good races and good racing on track. Maybe I'm right, maybe I'm wrong the rules for 2023 haven't changed that much, the cars need to be raised a little bit more, the floors are gonna be tightened and the rule up is gonna be stronger but the rules are staying pretty much the same which make me feel that Red Bulls should still be at the front, Ferrari should still have a very good baseline and Mercedes has learned a lot from 2022 and it's gonna be strong next year. Point number two, Piastri vs Norris. I'm excited to see what Oscar Piastri can do in Formula One. He didn't have the best entry with all the Alpine McLaren story, he's in a great car, in a great team next to a very strong teammate that has made the McLaren team his own team so never easy to enter that web, but also a good point as a rookie to come into a team that has an established driver which is pretty young and kind of come from the same background you know Formula Three, Formula Two and no Formula One. So I'm excited to see what Oscar Piastri can do there, I think it's definitely one of those seats that you really want to be in when you get to Formula One so that's something I'm gonna keep an eye on. Number three, talking of young driver, less young driver or more experienced driver, Fernando Alonso.  Every session, every lap, every practice, his full-on, his sliding car, he's going for it and I'm excited to see with Aston Martin what the challenge can be.  We've seen Fernando Alonso changing a lot of teams through the year, not always for the best, but I'm truly hoping that he's gonna get a good car and give us some of the performances that he's able to do. Remember, Canada qualifying in 2022 is third on the grid, Wales because he's super strong, there was another wet qualifying so it's gone on top of my head but it was off there. Remember, Austin 2022, he flew up in the air with his next future teammate, his future teammate, Lance Stroll, car landed, finished the race, still score points, so absolutely stunning on that one. And then number four, the French duo. I'm excited to see what Alpin's gonna do with two French drivers. It can go bad, let me not lie to you, it can go bad if each of the drivers wants to be their French driver doing their job for their French team, it can go south, but it can also go really well. It can also be that those two guys that were not the best friend in their age have matured a lot, they're both race winners, they have the same palm allies, they both have one race win. If they go on nicely together and they work well, that could be a really cool success story for Alpin. That's my wish, obviously, the French driver, I hope they're gonna go on together nicely, they're gonna do a good job, Alpin's gonna keep building up of that momentum of 2022, finishing fourth in the Constrictor Championship with those two experienced drivers doing a good job, but they need to keep an eye on that relationship between the two because if it starts being a fight, ego fight, a fight to be the best French driver on the grid for the French team, then things can go bad. So those are the four things that I'm really looking forward to see in 2023. Please, I also like, subscribe, make a comment, tell me what you're looking forward in 2023. There is more, obviously, there's Logan Sargent, the American driver coming to Williams, there's Nick DeVries, Fulltime, Zafatory, there's more, but I just picked up four points so we don't stay here for a too long time and those are my points, but make sure that you give me yours and as I say, very soon I'm gonna do some more videos about the top team and what I expect from each of those guys as well as how do we set up a Formula 1 car. Thank you and I'll see you very soon.


we have developed a model for understanding the molecular orientation disorder in CH3 and H3PBI3, which is used to inform the motion of the molecules. The model was based on electronic structure calculations and a Benitio molecular dynamics simulations. It revealed a rich domain structure of twinned molecular dipoles, which varies depending on temperature and applied electric field. This variation can be attributed to the internal electrical fields associated with microscopic polarization domains, which may contribute to hysteresis in the current voltage response of hybrid organic and organic perovskite solar cells. This article was authored by Jarvis M. Frost, Keith T. Butler, and Aaron Walsh.


My name is Bimbika Sijapati Basna. I'm a scientist at the Centre for International Forestry Research. There's quite a lot of research and evidence on the social and economic implications of all-palm expansion that's emerging from Indonesia, but most of that research really doesn't focus on gender issues. Women play a very important role in all-palm as workers, as part of smallholder households, as communities who are affected by the expansion. So our research really sought to shed light on gender issues, on women's issues. This area was particularly interesting for us because the entire landscape has really changed in the last 10, 15 years because of expansion. Our research was looking at a couple of things. So first was how do the acquisition process unfold? What were the community, company, government, officials, dynamics like? And then we were looking at how are people currently engaged in all-palm? What do they think about it? What are some of the challenges they've faced? One major finding was that there's a lot of dissatisfaction amongst the communities with the ways in which large-scale all-palm negotiations began. And a lot of people felt that the communities were really not on the same level playing field as the companies were. This is because the concession permits were already granted to the companies, so before they even entered into negotiations with the communities. The price of the land that the communities had to give away to make way for all-palm was also determined by the company. And also the company had promised that if communities participate that they would receive regular decent income, but in reality the dividends that the communities have received have been quite limited. Women have faced an additional layer of dispossession because they were really not a part of the negotiation process at all. And yet large tracts of the land that was given away to make for all-palm was actually sweetened land that women managed for family food provisioning. People aren't against all-palm per se, but they have a lot of dissatisfaction with the ways in which large-scale all-palm unfolded. All-palm has come with a lot of benefits. People have access to infrastructure, which means that they can then access markets, they can access educational facilities, health facilities. And all-palm has also come up with a lot of employment opportunities, and women in particular have benefited from that. And the wages that they earn from all-palm has been an important part of household income. Having said that, and most of them are employed just as casual workers, so they get wage as per how much they are able to do during that day. And the targets that are set are really, really high, so it's very difficult to work. In addition to that, women also have to go on with their regular activities. So all-palm then becomes one job that they do in addition to other jobs, which includes providing for their households, looking after their children, looking after their families, taking care of their sweetened lands. So you see that all-palm, because of the terms and conditions of the employment, has really increased women's drudgery. We really don't want this research to be translated into a report that just sits in the shelf. So our hope is really to raise awareness about what are the key gender issues in the debate about sustainable oil palm, and really make sure that women's rights are safeguarded. And also there are opportunities, oil palm opens up opportunities for women's empowerment.


The story of the Exodus from Egypt, the Hijrah of Musa al-Islam and the Bani Israel, the Quranic versions of these narratives make much more historical sense than their Biblical counterparts. In other words, the flood of the Exodus, as described in the Bible, are basically historically impossible, or at least highly implausible. Somehow the Quran avoided many of the problematic historical claims of the Biblical authors. This is from the Dela'il An-Nabua. This is one of the proofs of prophecy. This is a proof that the Prophet Muhammad sallallahu alayhi sallam was a true Nabi, a true prophet. For example, I'll give you an example. The Bible says that 600,000 men of fighting age made Exodus from Egypt with Musa al-Islam. This means about 3 million people made Exodus from Egypt. If we count the women, the children, the elderly, not to mention animals, 3 million people plus livestock. This is almost falsifiable. This would mean that basically a third of the entire population of Egypt made Hijrah. This would have been noticed by other civilizations in that region, yet no one recorded it. 3 million people for 40 years would have left a major footprint in the Sinai desert. There is none. If 3 million people were marching, just to give you a visual or to conceptualize this a little bit, if 3 million people were marching, 10 men across when the first row reached Mount Sinai, the last row would have still been in Egypt. What does Allah subhanahu wa ta'ala say in the Quran? The Exodus is confirmed in its general sense in the Quran, but there are changes that Allah subhanahu wa ta'ala makes in the narrative that are extremely important and often overlooked by even scholars, let alone average readers. Allah subhanahu wa ta'ala says wa awhayna ila Musa an asli bi-ibadi. Inna kum muttaba'un. We reveal to Musa al-Islam. Already under the cover of night with my servants, indeed you will be pursued. So they all left in one night. Fa arasallah fir'awna fil mad'aini hashirin, and fir'awn Pharaoh sent summoners to the cities.  How many Sahaba made hijra from Mecca to Medina during the time of the Prophet Sallallahu alayhi wa sallam? It was a small group. The Biblical version of the exodus cannot be true historically, while the Quranic version is very plausible.


Hey everybody, this is a swing trade swing signals recap today is Friday, April 17th and as you know that there is some kind of bullish sentiment come into the markets because of this drug by by Gilead Sciences and we are closing a lot of our swing trades today. We are you won't believe in this in this kind of an environment our trades are doing fantastic. So here you'll see that Microsoft is up three almost close to 3000 Costco is up another 1400. Then booking went up very nicely on this iron condo backspread combination and Amazon we are recovering we are going to be break even on this trade. Tesla also we just closed out this trade today for a profit of about 1200 and then a couple of you know small trades we are closing out the Wix trade as well as TLT and gold and things like that. So even in this volatile month of March of sorry April 2020 in the Corona world I think in April we've done about I would say close to about $7000 to $8000 in profit. So if you want to know more about the swing signals program just watch the end of this video and you can sign up on the website. Thanks. If you want to join the swing trading signals program you can go to this bit.ly link HTTP bit.ly slash 25 swing to get a 25% discount on the monthly plan. You can also come to the option tiger website at option tiger.com and on the homepage itself you'll see the algorithm based swing trading signal service. If you click on learn more that will take you to the swing trading signals page. And here you can get some more details on it and you can also sign up on a monthly plan for 25% off or an annual plan for 50% off the list price. Thank you.