Talk is about simple data structures like queue and Tree and their possible implementation in Scala. It also talks about binary search trees and their traversals.
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit โ Haskell and...Philip Schwarz
ย
First see the problem solved using the List monad and a Scala for comprehension.
Then see the Scala program translated into Haskell, both using a do expressions and using a List comprehension.
Understand how the Scala for comprehension is desugared, and what role the withFilter function plays.
Also understand how the Haskell do expressions and List comprehension are desugared, and what role the guard function plays.
Scala code for Part 1: https://github.com/philipschwarz/n-queens-combinatorial-problem-scala-part-1
Errata: on slide 30, the resulting lists should be Haskell ones rather than Scala ones.
(Video of these slides here http://fsharpforfunandprofit.com/rop)
(My response to "this is just Either" here: http://fsharpforfunandprofit.com/rop/#monads)
Many examples in functional programming assume that you are always on the "happy path". But to create a robust real world application you must deal with validation, logging, network and service errors, and other annoyances.
So, how do you handle all this in a clean functional way? This talk will provide a brief introduction to this topic, using a fun and easy-to-understand railway analogy.
The document provides an overview of higher-kinds, typeclasses, type-level encodings, and continuations in Scala. It discusses how kind systems classify types, how typeclasses allow abstraction over types, and examples of encoding data structures like linked lists at the type level. It also introduces delimited continuations in Scala and how they can be used to simulate control flow constructs like break statements.
The document discusses the Uniform Access Principle, which states that all services offered by a module should be available through a uniform notation that does not reveal whether they are implemented through storage or computation. It provides examples of how different languages do or do not follow this principle, and explains that following this principle helps avoid breaking client code when implementation details change. It also discusses how Scala supports the Uniform Access Principle for parameterless methods.
download for better quality - Learn about the sequence and traverse functions
through the work of Runar Bjarnason and Paul Chiusano, authors of Functional Programming in Scala https://www.manning.com/books/functional-programming-in-scala
Monad as functor with pair of natural transformationsPhilip Schwarz
ย
Explains why a Monad is a functor with a pair of natural transformations (plus associativity and identity laws). It then explores this by looking at an example, with code in Scala.
Inspired and based on videos/publications by Bartosz Milewski, Rรบnar Bjarnason and Rob Norris.
Download for better quality.
Why functional programming and category theory strongly mattersPiotr Paradziลski
ย
Abstractions of Category Theory to define abstractions (Functor, Applicative, Monad, Comonad, Coyoneda) commonly used in functional programming (FP). Using definitions from Category Theory to reason about modular and composable design. Examples based on Haskell papers: Functional pearls translated to Scala.
Introduces the functional programming ideas of Functor, Apply, Applicative And Monad. Shows how to implement each in Scala with Scalaz and how to validate the implementation using property based test using specs2 and scalacheck.
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
ย
- The document describes how product types (built using AND) and sum types (built using OR) are used to define types for representing fruit salads and fruit snacks in F#, Haskell, Scala, and Java.
- Product types combine elements and are used to define the FruitSalad type, while sum types allow alternatives and are used to define the FruitSnack type consisting of different fruits.
- Pattern matching is demonstrated to write functions that analyze and return different strings based on the values of FruitSalad and FruitSnack types.
This document provides a 3-sentence summary of the given document:
The document is a tutorial introduction to high-performance Haskell that covers topics like lazy evaluation, reasoning about space usage, benchmarking, profiling, and making Haskell code run faster. It explains concepts like laziness, thunks, and strictness and shows how to define tail-recursive functions, use foldl' for a strict left fold, and force evaluation of data constructor arguments to avoid space leaks. The goal is to help programmers optimize Haskell code and make efficient use of multiple processor cores.
For decades, the Functor, Monoid, and Foldable type class hierarchies have dominated functional programming. Implemented in libraries like Scalaz and Cats, these type classes have an ancient origin in Haskell, and they have repeatedly proven useful for advanced functional programmers, who use them to maximize code reuse and increase code correctness.
Yet, as these type classes have been copied into Scala and aged, there is a growing awareness of their drawbacks, ranging from being difficult to teach to weird operators that donโt make sense in Scala (ap from Applicative), to overlapping and lawless type classes (Semigroupal), to a complete inability to abstract over data types that possess related structure (such as isomorphic applicatives).
In this presentation, John A. De Goes introduces a new Scala library with a completely different factoring of functional type classesโone which throws literally everything away and starts from a clean slate. In this new factoring, type classes leverage Scalaโs strengths, including variance and modularity. Pieces fit together cleanly and uniformly, and in a way that satisfies existing use cases, but enables new ones never before possible. Finally, type classes are named, organized, and described in a way that makes teaching them easier, without compromising on algebraic principles.
If youโve ever thought functional type classes were too impractical or too confusing or too restrictive, nowโs your chance to get a fresh perspective on a library that just might make understanding functional programming easier than ever before!
ZIO-Direct allows direct style programming with ZIO. This library provides a *syntactic sugar* that is more powerful than for-comprehensions as well as more natural to use. Simply add the `.run` suffix to any ZIO effect in order to retrieve it's value.
At the heart of data processing, event-sourcing, actors, and much more is the queueโa data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goesโarchitect of the Scalaz 8 effect systemโintroduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Boost your productivity with Scala tooling!MeriamLachkar1
ย
Our rich ecosystem provides developers with powerful tools that improve productivity on small or huge projects.
In this talk, I will present the tools that allow me to focus on my projects by making tedious tasks easier. From bootstrapping projects, to code linting and refactoring, from continuous integration and automatic publication and documentation rendering, come discover my favorite tools.
With my simple implementation I wanted to demonstrate the basic ideas of th IO Monad.
My impl of the IO Monad is just a feasibility study, not production code!
When coding my impl of IO I was very much inspired by cats.effect.IO and monix.eval.Task which I studied at that time. Both are implementions of the IO Monad.
The API of my IO is very similar to the basics of Monix Task. This IO implementation also helped me to understand the IO Monad (of cats-effect) and Monix Task.
Interop with Future is also supported. You can convert IO to a Future. Vice versa you can convert a Future to an IO.
The development of my impl can be followed step by step in the code files in package iomonad.
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Philip Schwarz
ย
(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes.
Follow along as the fold abstraction is introduced and explained.
Watch as folding is used to simplify the definition of recursive functions over recursive datatypes
Part 1 - through the work of Richard Bird and Graham Hutton.
This version corrects the following issues:
slide 7, 11 fib(0) is 0,rather than 1
slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala
slide 36: concat not invoked in concat example
slides 48 and 49: unwanted 'm' in definition of sum
throughout: a couple of typographical errors
throughout: several aesthetic imperfections (wrong font, wrong font colour)
The document discusses LDAP injection attacks and techniques for exploiting vulnerabilities in LDAP directory services. It describes how LDAP injections work similarly to SQL injections by manipulating LDAP query parameters. This allows attackers to alter queries and access unauthorized data. The document outlines different types of LDAP injections, such as AND, OR, and blind injections. It also discusses techniques for discovering directory information through data booleanization and charset reduction when only true/false responses are available. Finally, it recommends input filtering and limiting query syntax to help prevent LDAP injections.
Left and Right Folds- Comparison of a mathematical definition and a programm...Philip Schwarz
ย
We compare typical definitions of the left and right fold functions, with their mathematical definitions in Sergei Winitzkiโs upcoming book: The Science of Functional Programming.
Errata:
Slide 13: "The way ๐๐๐๐๐ does it is by associating to the right" - should, of course ,end in "to the left".
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
End-to-end Data Pipeline with Apache SparkDatabricks
ย
This document discusses Apache Spark, a fast and general cluster computing system. It summarizes Spark's capabilities for machine learning workflows, including feature preparation, model training, evaluation, and production use. It also outlines new high-level APIs for data science in Spark, including DataFrames, machine learning pipelines, and an R interface, with the goal of making Spark more similar to single-machine libraries like SciKit-Learn. These new APIs are designed to make Spark easier to use for machine learning and interactive data analysis.
Traverse allows running actions over data structures and accumulating results. It traverses data like lists and vectors, running an applicative functor like Future or Option for each element. Variations include parallel, non-empty, unordered, and flat traversals. Traverse underpins many operations and is a powerful abstraction for representing imperative loops in a functional way.
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziลski
ย
A big picture of category theory in Scala - starting from regular functors with additional structure (Apply, Applicative, Monad) to Comonads. Usually, we think about structures like Monoids in a monoidal category with particular tensor. In here I analyze just signatures of different abstractions.
Exploration of Contravariant functors as a way to model computation "backward" or abstract over input with the ability to prepend operation. Examples for predicates, sorting, show and function input (or any other function parameter except the last one).
Profunctors as abstraction unifying Functors and Contravariant functors to model both input and output. Example for Profunctor - function with one argument.
Relation to Bifunctors, Kan extensions, Adjunctions, and Free constructions.
Functional programming can be an excellent approach to designing decoupled, reusable systems with a rich domain model. In fact, the lessons from applying DDD in a functional language translate well to object-oriented programming.
The lazy programmer's guide to writing thousands of testsScott Wlaschin
ย
We are all familiar with example-based testing, as typified by TDD and BDD, where each test is hand-crafted.
But there's another approach to writing tests. In the "property-based testing" approach, a single test is run hundreds of times with randomly generated inputs. Property-based testing is a great way to find edge cases, and also helps you to understand and document the behavior of your code under all conditions.
This talk will introduce property-based testing, show you how it works, and demonstrate why you should consider adding this powerful technique to your toolbelt.
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...PROIDEA
ย
Contact
FUNCTIONAL PROGRAMING AND EVENT SOURCING - A PAIR MADE IN HEAVEN - EXTENDED, 2 HOURS LONG BRAINWASH
TL;DR: This is talk is a solid introduction to two (supposedly) different topics: FP & ES. I will cover both the theory and the practice. We will emerage ES+FP application starting from ES+OO one.
While reading blogs or attending conferences, you might have heard about Event Sourcing. But didn't you get this feeling, that while there is a lot of theory out there, it is really hard to see a hands-on example? And even if you find some, those are always orbiting around Object Oriented concepts?
Greg Young once said "When we talk about Event Sourcing, current state is a left-fold of previous behaviours. Nothing new to Functional Programmers". If Functional Programming is such a natural concept for event sourced systems, shouldn't they fit together on a single codebase?
In this talk we will quickly introduce Event Sourcing (but without going into details), we will introduce some functional concepts as well (like State monad). Armoured with that knowledge we will try to transform sample ES application (OO-style, tightly coupled with framework) to frameworkless, FP-style solution).
Talk is targeted for beginner and intermediate audience. Examples will be in Scala but nothing fancy - normal syntax.
This talk is an extended version of a presentation "Event Sourcing & Functional Programming - a pair made in heaven". It is enriched with content of presentations: "Monads - asking the right question" and "It's all been done before - The Hitchhiker's Guide to Time Travel".
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Why functional programming and category theory strongly mattersPiotr Paradziลski
ย
Abstractions of Category Theory to define abstractions (Functor, Applicative, Monad, Comonad, Coyoneda) commonly used in functional programming (FP). Using definitions from Category Theory to reason about modular and composable design. Examples based on Haskell papers: Functional pearls translated to Scala.
Introduces the functional programming ideas of Functor, Apply, Applicative And Monad. Shows how to implement each in Scala with Scalaz and how to validate the implementation using property based test using specs2 and scalacheck.
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
ย
- The document describes how product types (built using AND) and sum types (built using OR) are used to define types for representing fruit salads and fruit snacks in F#, Haskell, Scala, and Java.
- Product types combine elements and are used to define the FruitSalad type, while sum types allow alternatives and are used to define the FruitSnack type consisting of different fruits.
- Pattern matching is demonstrated to write functions that analyze and return different strings based on the values of FruitSalad and FruitSnack types.
This document provides a 3-sentence summary of the given document:
The document is a tutorial introduction to high-performance Haskell that covers topics like lazy evaluation, reasoning about space usage, benchmarking, profiling, and making Haskell code run faster. It explains concepts like laziness, thunks, and strictness and shows how to define tail-recursive functions, use foldl' for a strict left fold, and force evaluation of data constructor arguments to avoid space leaks. The goal is to help programmers optimize Haskell code and make efficient use of multiple processor cores.
For decades, the Functor, Monoid, and Foldable type class hierarchies have dominated functional programming. Implemented in libraries like Scalaz and Cats, these type classes have an ancient origin in Haskell, and they have repeatedly proven useful for advanced functional programmers, who use them to maximize code reuse and increase code correctness.
Yet, as these type classes have been copied into Scala and aged, there is a growing awareness of their drawbacks, ranging from being difficult to teach to weird operators that donโt make sense in Scala (ap from Applicative), to overlapping and lawless type classes (Semigroupal), to a complete inability to abstract over data types that possess related structure (such as isomorphic applicatives).
In this presentation, John A. De Goes introduces a new Scala library with a completely different factoring of functional type classesโone which throws literally everything away and starts from a clean slate. In this new factoring, type classes leverage Scalaโs strengths, including variance and modularity. Pieces fit together cleanly and uniformly, and in a way that satisfies existing use cases, but enables new ones never before possible. Finally, type classes are named, organized, and described in a way that makes teaching them easier, without compromising on algebraic principles.
If youโve ever thought functional type classes were too impractical or too confusing or too restrictive, nowโs your chance to get a fresh perspective on a library that just might make understanding functional programming easier than ever before!
ZIO-Direct allows direct style programming with ZIO. This library provides a *syntactic sugar* that is more powerful than for-comprehensions as well as more natural to use. Simply add the `.run` suffix to any ZIO effect in order to retrieve it's value.
At the heart of data processing, event-sourcing, actors, and much more is the queueโa data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goesโarchitect of the Scalaz 8 effect systemโintroduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Boost your productivity with Scala tooling!MeriamLachkar1
ย
Our rich ecosystem provides developers with powerful tools that improve productivity on small or huge projects.
In this talk, I will present the tools that allow me to focus on my projects by making tedious tasks easier. From bootstrapping projects, to code linting and refactoring, from continuous integration and automatic publication and documentation rendering, come discover my favorite tools.
With my simple implementation I wanted to demonstrate the basic ideas of th IO Monad.
My impl of the IO Monad is just a feasibility study, not production code!
When coding my impl of IO I was very much inspired by cats.effect.IO and monix.eval.Task which I studied at that time. Both are implementions of the IO Monad.
The API of my IO is very similar to the basics of Monix Task. This IO implementation also helped me to understand the IO Monad (of cats-effect) and Monix Task.
Interop with Future is also supported. You can convert IO to a Future. Vice versa you can convert a Future to an IO.
The development of my impl can be followed step by step in the code files in package iomonad.
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - with ...Philip Schwarz
ย
(download for perfect quality) - See how recursive functions and structural induction relate to recursive datatypes.
Follow along as the fold abstraction is introduced and explained.
Watch as folding is used to simplify the definition of recursive functions over recursive datatypes
Part 1 - through the work of Richard Bird and Graham Hutton.
This version corrects the following issues:
slide 7, 11 fib(0) is 0,rather than 1
slide 23: was supposed to be followed by 2-3 slides recapitulating definitions of factorial and fibonacci with and without foldr, plus translation to scala
slide 36: concat not invoked in concat example
slides 48 and 49: unwanted 'm' in definition of sum
throughout: a couple of typographical errors
throughout: several aesthetic imperfections (wrong font, wrong font colour)
The document discusses LDAP injection attacks and techniques for exploiting vulnerabilities in LDAP directory services. It describes how LDAP injections work similarly to SQL injections by manipulating LDAP query parameters. This allows attackers to alter queries and access unauthorized data. The document outlines different types of LDAP injections, such as AND, OR, and blind injections. It also discusses techniques for discovering directory information through data booleanization and charset reduction when only true/false responses are available. Finally, it recommends input filtering and limiting query syntax to help prevent LDAP injections.
Left and Right Folds- Comparison of a mathematical definition and a programm...Philip Schwarz
ย
We compare typical definitions of the left and right fold functions, with their mathematical definitions in Sergei Winitzkiโs upcoming book: The Science of Functional Programming.
Errata:
Slide 13: "The way ๐๐๐๐๐ does it is by associating to the right" - should, of course ,end in "to the left".
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
End-to-end Data Pipeline with Apache SparkDatabricks
ย
This document discusses Apache Spark, a fast and general cluster computing system. It summarizes Spark's capabilities for machine learning workflows, including feature preparation, model training, evaluation, and production use. It also outlines new high-level APIs for data science in Spark, including DataFrames, machine learning pipelines, and an R interface, with the goal of making Spark more similar to single-machine libraries like SciKit-Learn. These new APIs are designed to make Spark easier to use for machine learning and interactive data analysis.
Traverse allows running actions over data structures and accumulating results. It traverses data like lists and vectors, running an applicative functor like Future or Option for each element. Variations include parallel, non-empty, unordered, and flat traversals. Traverse underpins many operations and is a powerful abstraction for representing imperative loops in a functional way.
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziลski
ย
A big picture of category theory in Scala - starting from regular functors with additional structure (Apply, Applicative, Monad) to Comonads. Usually, we think about structures like Monoids in a monoidal category with particular tensor. In here I analyze just signatures of different abstractions.
Exploration of Contravariant functors as a way to model computation "backward" or abstract over input with the ability to prepend operation. Examples for predicates, sorting, show and function input (or any other function parameter except the last one).
Profunctors as abstraction unifying Functors and Contravariant functors to model both input and output. Example for Profunctor - function with one argument.
Relation to Bifunctors, Kan extensions, Adjunctions, and Free constructions.
Functional programming can be an excellent approach to designing decoupled, reusable systems with a rich domain model. In fact, the lessons from applying DDD in a functional language translate well to object-oriented programming.
The lazy programmer's guide to writing thousands of testsScott Wlaschin
ย
We are all familiar with example-based testing, as typified by TDD and BDD, where each test is hand-crafted.
But there's another approach to writing tests. In the "property-based testing" approach, a single test is run hundreds of times with randomly generated inputs. Property-based testing is a great way to find edge cases, and also helps you to understand and document the behavior of your code under all conditions.
This talk will introduce property-based testing, show you how it works, and demonstrate why you should consider adding this powerful technique to your toolbelt.
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...PROIDEA
ย
Contact
FUNCTIONAL PROGRAMING AND EVENT SOURCING - A PAIR MADE IN HEAVEN - EXTENDED, 2 HOURS LONG BRAINWASH
TL;DR: This is talk is a solid introduction to two (supposedly) different topics: FP & ES. I will cover both the theory and the practice. We will emerage ES+FP application starting from ES+OO one.
While reading blogs or attending conferences, you might have heard about Event Sourcing. But didn't you get this feeling, that while there is a lot of theory out there, it is really hard to see a hands-on example? And even if you find some, those are always orbiting around Object Oriented concepts?
Greg Young once said "When we talk about Event Sourcing, current state is a left-fold of previous behaviours. Nothing new to Functional Programmers". If Functional Programming is such a natural concept for event sourced systems, shouldn't they fit together on a single codebase?
In this talk we will quickly introduce Event Sourcing (but without going into details), we will introduce some functional concepts as well (like State monad). Armoured with that knowledge we will try to transform sample ES application (OO-style, tightly coupled with framework) to frameworkless, FP-style solution).
Talk is targeted for beginner and intermediate audience. Examples will be in Scala but nothing fancy - normal syntax.
This talk is an extended version of a presentation "Event Sourcing & Functional Programming - a pair made in heaven". It is enriched with content of presentations: "Monads - asking the right question" and "It's all been done before - The Hitchhiker's Guide to Time Travel".
Binary search trees have the following key properties:
1. Each node contains a value.
2. The left subtree of a node contains only values smaller than the node's value.
3. The right subtree of a node contains only values larger than the node's value.
Binary search trees allow for efficient insertion and search operations in O(log n) time due to their structure. Deletion may require rebalancing the tree to maintain the binary search tree properties.
Zippers are a design pattern in functional programming languages, such as Haskell, which provides a focus point and methods for navigating around in a functional data structure. It turns out that for any algebraic data type with one parameter, the derivative of the type is a zipper for it.
This document contains examples of Lisp code defining functions for calculating areas and volumes of geometric shapes, averaging values, and comparing numbers. It also includes sections about lists, expressions, defining procedures, variables, manipulating lists, strings, printing, testing results, and creating dialogue boxes in Lisp.
The document discusses functional programming concepts in Scala including pure functions, referential transparency, algebraic data types, immutable linked lists, list folding, option types, higher order functions, and random number generation. It provides code examples for implementing immutable linked lists with pattern matching, list folding with foldLeft and foldRight, mapping, filtering and flatMapping lists, and defining monads and functors in Scala.
The document discusses various data structures in Scala including queues and binary search trees. It describes functional queues in Scala as immutable data structures with head, tail, and enqueue operations. It also covers different implementations of queues and optimizations. For binary search trees, it explains the binary search tree property, provides a Tree class representation in Scala, and algorithms for in-order, pre-order, and post-order tree traversals along with their Scala implementations.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, membership testing, and type conversions.
2) Common loop statements in Python are for loops and while loops. For loops iterate over sequences, while loops repeat as long as a condition is true. Loop control statements like break, continue, and else can be used to control loop execution.
3) Functions are defined using the def keyword and can take parameters and return values. Functions allow for code reusability and organization. Built-in functions operate on containers to provide functionality like sorting, summing, and converting between types.
1) Base types in Python include integers, floats, booleans, strings, bytes, lists, tuples, dictionaries, sets, and None. These types support various operations like indexing, slicing, mathematical operations, membership testing, etc.
2) Functions are defined using the def keyword and can take parameters and return values. Functions are called by specifying the function name followed by parentheses that may contain arguments.
3) Common operations on containers in Python include getting the length, minimum/maximum values, sum, sorting, checking for membership, enumerating, and zipping containers. Methods like append, extend, insert, remove, pop can modify lists in-place.
The document discusses binary search trees (BSTs) and their use as a data structure for dynamic sets. It covers BST properties, operations like search, insert, delete and their running times. It also discusses using BSTs to sort an array in O(n lg n) time by inserting elements, similar to quicksort. Maintaining a height of O(lg n) is important for efficient operations.
The document discusses binary search trees and their properties. It explains that a binary search tree is a binary tree where every node's left subtree contains values less than the node's value and the right subtree contains greater values. Operations like search, insert, delete can be done in O(h) time where h is the height of the tree. The height is O(log n) for balanced trees but can be O(n) for unbalanced trees. The document also provides examples of using a binary search tree to sort a set of numbers in O(n log n) time by building the BST and doing an inorder traversal.
1. Python provides various built-in container types including lists, tuples, dictionaries, sets, and strings for storing and organizing data.
2. These container types support common operations like indexing, slicing, membership testing, and methods for insertion, deletion, and modification.
3. The document provides examples of using operators and built-in functions to perform tasks like formatting strings, file I/O, conditional logic, loops, functions, and exceptions.
This document provides a summary of key Python concepts including:
1. Base data types like integers, floats, booleans, strings, lists, tuples, dictionaries, sets, and None.
2. Variables, assignments, identifiers, conversions between types, and string formatting.
3. Conditional statements like if/elif/else and boolean logic operators.
4. Loops like for and while loops for iterating over sequences.
5. Functions for defining reusable blocks of code and calling functions.
1) This document provides an overview of key Python concepts including data types, variables, operators, conditional and loop statements, functions, modules and various operations that can be performed on common container types like lists, tuples, dictionaries and sets.
2) It describes Python's basic types like integers, floats, booleans, strings and how to define variables and perform assignments. Common operators for math, comparisons, logic and assignments are also covered.
3) The document outlines control flow statements like if/else, while and for loops and includes examples of iterating over sequences and containers. It also covers defining and calling functions.
LISP Language, LISP Introduction, List Processing, LISP Syntax, Lisp Comparison Structures, Lisp Applications. Using of LISP language in Artificial Intelligence
This document provides an introduction to functional programming concepts in Scala including mutability, functions as first-class citizens, closures, pattern matching, recursion, lazy vs eager evaluation, type classes, ad-hoc polymorphism, concurrency, and functional data structures. It also briefly mentions additional Scala concepts that could be covered like existential types, self types, structural typing, compile-time metaprogramming, reactive programming with Akka, and more advanced functional programming topics.
The document discusses red-black trees, which are binary search trees augmented with node colors to guarantee a height of O(log n). It describes the properties that red-black trees must satisfy, including that every node is red or black, leaves are black, and if a node is red its children are black. It then proves that these properties ensure the height is O(log n) by showing a subtree has at least 2^bh - 1 nodes, where bh is the black-height. Finally, it notes that common operations like search, insert and delete run in O(log n) time on red-black trees.
This document provides a cheat sheet for common commands and functions in R for data manipulation, statistical analysis, and graphics. It summarizes key topics such as accessing and manipulating data, conducting statistical tests, fitting linear and generalized linear models, performing clustering and multivariate analyses, and creating basic plots and graphics. The cheat sheet is organized into sections covering basics, vectors and data types, data frames, input/output, indexing, missing values, numerical and tabulation functions, programming, operators, graphics, and statistical models and distributions.
The document describes depth-first search (DFS) of a graph. It discusses applications of DFS such as finding paths between nodes and determining if a graph is connected. It then explains the concepts of a depth-first tree, back edges, and cross edges. Finally, it provides pseudocode for a recursive and iterative DFS algorithm that uses data structures like a stack and arrays to track node labels, parents, and next nodes to visit.
This document discusses binary search trees (BSTs) and their use for dynamic sets and sorting. It covers BST operations like search, insert, find minimum/maximum, and delete. It explains that BST sorting runs in O(n log n) time like quicksort. Maintaining a height of O(log n) can lead to efficient implementations of priority queues and other dynamic set applications using BSTs.
"Rebranding for Growth", Anna VelykoivanenkoFwdays
ย
Since there is no single formula for rebranding, this presentation will explore best practices for aligning business strategy and communication to achieve business goals.
Role of Data Annotation Services in AI-Powered ManufacturingAndrew Leo
ย
From predictive maintenance to robotic automation, AI is driving the future of manufacturing. But without high-quality annotated data, even the smartest models fall short.
Discover how data annotation services are powering accuracy, safety, and efficiency in AI-driven manufacturing systems.
Precision in data labeling = Precision on the production floor.
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfAbi john
ย
Analyze the growth of meme coins from mere online jokes to potential assets in the digital economy. Explore the community, culture, and utility as they elevate themselves to a new era in cryptocurrency.
Rock, Paper, Scissors: An Apex Map Learning JourneyLynda Kane
ย
Slide Deck from Presentations to WITDevs (April 2021) and Cleveland Developer Group (6/28/2023) on using Rock, Paper, Scissors to learn the Map construct in Salesforce Apex development.
AI Changes Everything โ Talk at Cardiff Metropolitan University, 29th April 2...Alan Dix
ย
Talk at the final event of Data Fusion Dynamics: A Collaborative UK-Saudi Initiative in Cybersecurity and Artificial Intelligence funded by the British Council UK-Saudi Challenge Fund 2024, Cardiff Metropolitan University, 29th April 2025
https://alandix.com/academic/talks/CMet2025-AI-Changes-Everything/
Is AI just another technology, or does it fundamentally change the way we live and think?
Every technology has a direct impact with micro-ethical consequences, some good, some bad. However more profound are the ways in which some technologies reshape the very fabric of society with macro-ethical impacts. The invention of the stirrup revolutionised mounted combat, but as a side effect gave rise to the feudal system, which still shapes politics today. The internal combustion engine offers personal freedom and creates pollution, but has also transformed the nature of urban planning and international trade. When we look at AI the micro-ethical issues, such as bias, are most obvious, but the macro-ethical challenges may be greater.
At a micro-ethical level AI has the potential to deepen social, ethnic and gender bias, issues I have warned about since the early 1990s! It is also being used increasingly on the battlefield. However, it also offers amazing opportunities in health and educations, as the recent Nobel prizes for the developers of AlphaFold illustrate. More radically, the need to encode ethics acts as a mirror to surface essential ethical problems and conflicts.
At the macro-ethical level, by the early 2000s digital technology had already begun to undermine sovereignty (e.g. gambling), market economics (through network effects and emergent monopolies), and the very meaning of money. Modern AI is the child of big data, big computation and ultimately big business, intensifying the inherent tendency of digital technology to concentrate power. AI is already unravelling the fundamentals of the social, political and economic world around us, but this is a world that needs radical reimagining to overcome the global environmental and human challenges that confront us. Our challenge is whether to let the threads fall as they may, or to use them to weave a better future.
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxshyamraj55
ย
Weโre bringing the TDX energy to our community with 2 power-packed sessions:
๐ ๏ธ Workshop: MuleSoft for Agentforce
Explore the new version of our hands-on workshop featuring the latest Topic Center and API Catalog updates.
๐ Talk: Power Up Document Processing
Dive into smart automation with MuleSoft IDP, NLP, and Einstein AI for intelligent document workflows.
Leading AI Innovation As A Product Manager - Michael JidaelMichael Jidael
ย
Unlike traditional product management, AI product leadership requires new mental models, collaborative approaches, and new measurement frameworks. This presentation breaks down how Product Managers can successfully lead AI Innovation in today's rapidly evolving technology landscape. Drawing from practical experience and industry best practices, I shared frameworks, approaches, and mindset shifts essential for product leaders navigating the unique challenges of AI product development.
In this deck, you'll discover:
- What AI leadership means for product managers
- The fundamental paradigm shift required for AI product development.
- A framework for identifying high-value AI opportunities for your products.
- How to transition from user stories to AI learning loops and hypothesis-driven development.
- The essential AI product management framework for defining, developing, and deploying intelligence.
- Technical and business metrics that matter in AI product development.
- Strategies for effective collaboration with data science and engineering teams.
- Framework for handling AI's probabilistic nature and setting stakeholder expectations.
- A real-world case study demonstrating these principles in action.
- Practical next steps to begin your AI product leadership journey.
This presentation is essential for Product Managers, aspiring PMs, product leaders, innovators, and anyone interested in understanding how to successfully build and manage AI-powered products from idea to impact. The key takeaway is that leading AI products is about creating capabilities (intelligence) that continuously improve and deliver increasing value over time.
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersLynda Kane
ย
Slide Deck from Automation Dreamin'2022 presentation Sharing Some Gratitude with Your Users on creating a Flow to present a random statement of Gratitude to a User in Salesforce.
Dev Dives: Automate and orchestrate your processes with UiPath MaestroUiPathCommunity
ย
This session is designed to equip developers with the skills needed to build mission-critical, end-to-end processes that seamlessly orchestrate agents, people, and robots.
๐ Here's what you can expect:
- Modeling: Build end-to-end processes using BPMN.
- Implementing: Integrate agentic tasks, RPA, APIs, and advanced decisioning into processes.
- Operating: Control process instances with rewind, replay, pause, and stop functions.
- Monitoring: Use dashboards and embedded analytics for real-time insights into process instances.
This webinar is a must-attend for developers looking to enhance their agentic automation skills and orchestrate robust, mission-critical processes.
๐จโ๐ซ Speaker:
Andrei Vintila, Principal Product Manager @UiPath
This session streamed live on April 29, 2025, 16:00 CET.
Check out all our upcoming Dev Dives sessions at https://community.uipath.com/dev-dives-automation-developer-2025/.
Semantic Cultivators : The Critical Future Role to Enable AIartmondano
ย
By 2026, AI agents will consume 10x more enterprise data than humans, but with none of the contextual understanding that prevents catastrophic misinterpretations.
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxJustin Reock
ย
Building 10x Organizations with Modern Productivity Metrics
10x developers may be a myth, but 10x organizations are very real, as proven by the influential study performed in the 1980s, โThe Coding War Games.โ
Right now, here in early 2025, we seem to be experiencing YAPP (Yet Another Productivity Philosophy), and that philosophy is converging on developer experience. It seems that with every new method we invent for the delivery of products, whether physical or virtual, we reinvent productivity philosophies to go alongside them.
But which of these approaches actually work? DORA? SPACE? DevEx? What should we invest in and create urgency behind today, so that we donโt find ourselves having the same discussion again in a decade?
"Client Partnership โ the Path to Exponential Growth for Companies Sized 50-5...Fwdays
ย
Why the "more leads, more sales" approach is not a silver bullet for a company.
Common symptoms of an ineffective Client Partnership (CP).
Key reasons why CP fails.
Step-by-step roadmap for building this function (processes, roles, metrics).
Business outcomes of CP implementation based on examples of companies sized 50-500.
How Can I use the AI Hype in my Business Context?Daniel Lehner
ย
๐๐จ ๐ผ๐ ๐๐ช๐จ๐ฉ ๐๐ฎ๐ฅ๐? ๐๐ง ๐๐จ ๐๐ฉ ๐ฉ๐๐ ๐๐๐ข๐ ๐๐๐๐ฃ๐๐๐ง ๐ฎ๐ค๐ช๐ง ๐๐ช๐จ๐๐ฃ๐๐จ๐จ ๐ฃ๐๐๐๐จ?
Everyoneโs talking about AI but is anyone really using it to create real value?
Most companies want to leverage AI. Few know ๐ต๐ผ๐.
โ What exactly should you ask to find real AI opportunities?
โ Which AI techniques actually fit your business?
โ Is your data even ready for AI?
If youโre not sure, youโre not alone. This is a condensed version of the slides I presented at a Linkedin webinar for Tecnovy on 28.04.2025.
2. Agenda
โข Immutability & Persistence
โข Singly-Linked List
โข Bankerโs Queue
โข Binary Search Tree
โข Balanced BST: Red-Black Tree
โข Scala support of these things
โข Patricia Trie
โข Hash Array Mapped Trie
2
3. Immutability & Persistence
Two problems:
โข FP paradigm doesnโt support destructive updates
โข FP paradigm expects both the old and new
versions of DS will be available after update
Two solutions:
โข Immutable objects arenโt changeable
โข Persistent objects support multiple versions
3
4. Singly-Linked List
4
35 7
Cons
Nil
abstract sealed class List {
def head: Int
def tail: List
def isEmpty: Boolean
}
case object Nil extends List {
def head: Int = fail("Empty list.")
def tail: List = fail("Empty list.")
def isEmpty: Boolean = true
}
case class Cons(head: Int, tail: List = Nil) extends List {
def isEmpty: Boolean = false
}
5. List: analysis
5
35 7A =
B = Cons(9, A) = 9
C = Cons(1, Cons(8, B)) = 1 8
structural sharing
6. /**
* Time - O(1)
* Space - O(1)
*/
def prepend(x: Int): List = Cons(x, this)
/**
* Time - O(n)
* Space - O(n)
*/
def append(x: Int): List =
if (isEmpty) Cons(x)
else Cons(head, tail.append(x))
List: append & prepend
6
35 79
35 7 9
7. List: apply
7
35 7 42 6
n - 1
/**
* Time - O(n)
* Space - O(n)
*/
def apply(n: Int): A =
if (isEmpty) fail("Index out of bounds.")
else if (n == 0) head
else tail(n - 1) // or tail.apply(n - 1)
8. List: concat
8
path copying
A = 42 6
B = 35 7
C = A.concat(B) = 42 6
/**
* Time - O(n)
* Space - O(n)
*/
def concat(xs: List): List =
if (isEmpty) xs
else tail.concat(xs).prepend(head)
9. List: reverse (two approaches)
9
42 6 46 2reverse( ) =
def reverse: List =
if (isEmpty) Nil
else tail.reverse.append(head)
, or tail recursion in O(n)
The straightforward solution in O(n2)
def reverse: List = {
@tailrec
def loop(s: List, d: List): List =
if (s.isEmpty) d
else loop(s.tail, d.prepend(s.head))
loop(this, Nil)
}
11. Bankerโs Queue
โข Based on two lists (in and out)
โข Guarantees amortized O(1) performance
11
class Queue(in: List[Int] = Nil, out: List[Int] = Nil) {
def enqueue(x: Int): Queue = ???
def dequeue: (Int, Queue) = ???
def front: Int = dequeue match { case (a, _) => a }
def rear: Queue = dequeue match { case (_, q) => q }
def isEmpty: Boolean = in.isEmpty && out.isEmpty
}
12. Queue: analysis
12
A = new Queue( , )
B = A.enqueue(1) = 1 , )
C = B.enqueue(2) = 12 , )
D = C.enqueue(3) = 23 1 , )
(V, E) = D.dequeue = , ))2 3
(U, F) = E.dequeue = , ))3
reverse
new Queue(
new Queue(
new Queue(
(1, new Queue(
(2, new Queue(
13. Amortized vs. Average Case
โข Average Case analysis makes assumptions about
typical (most likely) input
โข Amortized analysis considers total performance of
sequence of operations in a the worst case
Example:
โข Dynamically-Resizing Array (java.util.ArrayList)
โ Has O(n) average case performance for add operation
โ It can be amortized to O(1)
โข Usually it takes O(1) since the storage is big enough
โข Sometimes it can take O(n) due to reallocation & copying
13
14. Queue: enqueue & dequeue
14
/**
* Time - O(1)
* Space - O(1)
*/
def enqueue(x: Int): Queue = new Queue(x :: in, out)
/**
* Time - O(1)
* Space - O(1)
*/
def dequeue: (Int, Queue) = out match {
case hd :: tl => (hd, new Queue(in, tl)) // O(1)
case Nil => in.reverse match { // O(n)
case hd :: tl => (hd, new Queue(Nil, tl))
case Nil => fail("Empty queue.")
}
}
21. BST: remove (code)
21
/**
* Time - O(log n)
* Space - O(log n)
*/
def remove(x: Int): Tree =
if (isEmpty) fail("Can't find " + x + " in this tree.")
else if (x < value) Branch(value, left.remove(x), right)
else if (x > value) Branch(value, left, right.remove(x))
else {
if (left.isEmpty && right.isEmpty) Leaf // case 1
else if (left.isEmpty) right // case 2
else if (right.isEmpty) left // case 2
else { // case 3
val succ = right.min // case 3
Branch(succ, left, right.remove(succ)) // case 3
}
}
22. /**
* Time - O(log n)
* Space - O(log n)
*/
def min: Int = {
@tailrec def loop(t: Tree, m: Int): Int =
if (t.isEmpty) m else loop(t.left, t.value)
if (isEmpty) fail("Empty tree.")
else loop(left, value)
}
/**
* Time - O(log n)
* Space - O(log n)
*/
def max: Int = {
@tailrec def loop(t: Tree[Int], m: Int): Int =
if (t.isEmpty) m else loop(t.right, t.value)
if (isEmpty) fail("Empty tree.")
else loop(right, value)
}
BST: min & max
22
5
2 7
1 3 8
5
2 7
1 3 8
23. BST: apply
23
5
2 7
1 3 6 8
n - 1
/**
* Time - O(log n)
* Space - O(log n)
*/
def apply(n: Int): A =
if (isEmpty) fail("Tree doesn't contain a " + n + "th element.")
else if (n < left.size) left(n)
else if (n > left.size) right(n - size - 1)
else value
30. Balanced BST: Red-Black Tree
โข Red invariant: No red node has red parent
โข Black invariant: Every root-to-leaf path contains
the same number of black nodes
โข Suggested by Chris Okasaki in his paper โRed-Black
Trees in a Functional Settingsโ
โข Asymptotically optimal implementation
โข Easy to understand and implement
30
31. R-B Tree chart sheet
31
z
y
x
x
y
z
z
y
x
z
x
y
x
z
y
Double Rotation
Double Rotation
Single Rotation
Single Rotation
32. R-B Tree: balanced insert
32
def balancedAdd(x: Int): Tree =
if (isEmpty) RedBranch(x)
else if (x < value) balance(isBlack, value, left.balancedAdd(x), right)
else if (x > value) balance(isBlack, value, left, right.balancedAdd(x))
else this
def balance(b: Boolean, x: Int, left: Tree, right: Tree): Tree =
(b, left, right) match {
case (true, RedBranch(y, RedBranch(z, a, b), c), d) =>
BlackBranch(y, RedBranch(z, a, b), RedBranch(x, c, d))
case (true, a, RedBranch(y, b, RedBranch(z, c, d))) =>
BlackBranch(y, RedBranch(x, a, b), RedBranch(z, c, d))
case (true, RedBranch(z, a, RedBranch(y, b, c)), d) =>
BlackBranch(y, RedBranch(z, a, b), RedBranch(x, c, d))
case (true, a, RedBranch(z, RedBranch(y, b, c), d)) =>
BlackBranch(y, RedBranch(x, a, b), RedBranch(z, c, d))
case (true, _, _) => BlackBranch(x, left, right)
case (false, _, _) => RedBranch(x, left, right)
}
33. What about Scala?
โข Scala has Singly-Linked List
โ scala.collection.immutable.List
โข Scala has Bankerโs Queue
โ scala.collection.immutable.Queue
โข Scala has Balanced BST (R-B Tree)
โ scala.collection.immutable.TreeSet
โ scala.collection.immutable.TreeMap
โข And a bit more โฆ
33