The document shows examples of using lambda functions and functional programming techniques in various languages like JavaScript, Python, C#, and Java. It demonstrates how to define anonymous functions, map, filter and reduce collections, use closures, and more. Key examples include summing a list of integers with reduce, filtering even numbers from a list, mapping string transformations, and converting a list of strings to uppercase.
The Ring programming language version 1.8 book - Part 29 of 202Mahmoud Samir Fayed
This document provides information on mathematical functions available in the Ring programming language. It lists common trigonometric, logarithmic, exponential and other mathematical functions like sin(), cos(), tan(), log(), sqrt(), random() and provides examples of using some of these functions to calculate values.
This document discusses ways to introduce functional programming concepts into Java code using existing Java 8 features, third-party libraries like Guava and LambdaJ, and by implementing common functional patterns and data structures yourself. It provides examples of using higher order functions, pure functions, recursion, and currying in Java code. It also summarizes capabilities of the Guava and LambdaJ libraries for functional programming in Java.
Referential Transparency, Higher Order functions, Lazy Evaluation, and Pattern Matching are key concepts in Functional Programming. Referential Transparency means that equal expressions can be replaced with each other without changing the program's behavior. Higher Order functions allow functions to be passed as arguments to other functions and returned as results. Lazy Evaluation delays evaluating arguments until their values are needed to avoid unnecessary computation. Pattern Matching allows decomposing and analyzing data structures.
The Ring programming language version 1.10 book - Part 30 of 212Mahmoud Samir Fayed
This document discusses lists in Ring programming language. It covers creating, accessing, modifying lists as well as common list operations like sorting, searching, reversing etc. Lists can contain other lists, allowing for nested data structures. Key points include:
- Lists are created using square brackets or range operators. Items can be added or removed using functions like Add(), Del().
- The len() function returns the number of items in a list. Individual items can be accessed using their index in square brackets.
- Common operations include sorting with sort(), reversing with reverse(), searching with find().
- Lists are passed by reference, so functions can modify the original list. They also support string indices to access items.
The Ring programming language version 1.9 book - Part 31 of 210Mahmoud Samir Fayed
This document provides documentation on mathematical functions available in the Ring programming language. It lists common trigonometric, logarithmic, exponential and other mathematical functions along with examples of their usage syntax and output. Key functions covered include sin(), cos(), tan(), log(), exp(), sqrt(), random(), ceil(), floor(), and others. Examples are provided to demonstrate calculating trigonometric functions with radians and degrees as well as functions returning random numbers, absolute values, powers and more.
This document discusses refactoring Java code to Clojure using macros. It provides examples of refactoring Java code that uses method chaining to equivalent Clojure code using the threading macros (->> and -<>). It also discusses other Clojure features like type hints, the doto macro, and polyglot projects using Leiningen.
The Ring programming language version 1.5.3 book - Part 22 of 184Mahmoud Samir Fayed
This document provides summaries of key features of lists in Ring programming language. Lists allow storing multiple values in a single variable. Key points include:
- Lists can be created using square brackets or : operator and items can be added or removed.
- Functions like len(), find(), sort(), reverse() etc. allow getting length, searching, sorting and reversing lists.
- Lists support nested structures and can be passed to and returned from functions.
- String indices can be used to access items in lists containing pairs of string and values.
- Lists provide a way to pass variable number of parameters to functions in a flexible order.
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
The Ring programming language version 1.5.1 book - Part 34 of 180Mahmoud Samir Fayed
The document describes various classes in the Ring standard library (stdlib) including the StdBase, String, List, Stack, Queue, HashTable, Tree, and Math classes. It provides details on their attributes and methods, and includes examples of using each class.
The document discusses functional programming concepts like pure functions, immutable data, and avoiding side effects. It compares imperative programming constructs like loops and mutable state to functional alternatives like map, filter, reduce. It argues that a functional style enables better reasoning about programs by avoiding side effects and complex control flow. Specific examples show transforming an imperative loop into a functional map and handling asynchronous code through chained promises or futures. Overall it advocates for a functional programming approach.
Arrays in JavaScript can store multiple data types. Common array methods allow users to manipulate array elements by adding, removing, and modifying items. Key methods include toString() and join() to convert arrays to strings, concat and push/pop to modify arrays, and filter(), map(), and reduce() to transform array elements.
Functional programming is usually classified as difficult. The jargon sounds scary and is creating a barrier to newcomers. This is a shame, since in the essence I would argue that functional programming is easier than object-oriented programming.
In this talk, I’ll outline the fundamentals of functional programming and we will take a look at some common constructs from the perspective of the foundations. Hopefully in the end you will walk away with your toes dipped into the world of functional programming wanting to know more. This talk is aimed for the object-oriented programmer. No prior knowledge about FP is required.
The Ring programming language version 1.5.3 book - Part 10 of 184Mahmoud Samir Fayed
This document summarizes the key features and changes in Ring 1.5.3, including:
- The trace library allows tracing function calls and opening an interactive debugger. An example uses a breakpoint.
- The type hints library allows adding type information to improve code editors and static analysis. It supports user-defined types.
- Overall the documentation and quality of Ring 1.5 has improved based on real-world usage.
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Waytdc-globalcode
This document discusses Domain Specific Languages (DSLs) in Kotlin and provides examples of building DSLs using Kotlin features like extension functions, operators, and receivers. It covers topics like infix notation, operator overloading, building query DSLs, mocking HTTP responses, and more. The document concludes that DSLs can improve existing domains and encourage designing your own DSLs for fun and learning.
This document provides a summary of key functions and commands in the R programming language for getting help, inputting and outputting data, creating and manipulating data, selecting and extracting data, performing mathematical operations, working with dates and times, plotting graphs, and more. It includes brief explanations and examples of commonly used functions like read.table(), plot(), hist(), summary(), str(), and others.
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 Ring programming language version 1.5.2 book - Part 33 of 181Mahmoud Samir Fayed
This document provides summaries of various functions available in the Ring standard library (stdlib). It describes functions for input/output like print(), puts(), getstring(), as well as string functions like split(), capitalized(), startswith(), endswith(). It also covers list functions like map(), filter(), value(), mathematical functions like factorial(), fibonacci(), and file functions like file2list(), list2file(). Examples are given to demonstrate the usage of each function.
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
An updated version of my talk on virtual machine cores comparing techniques in C and Go for implementing dispatch loops, stacks & hash maps.
Lots of tested and debugged code is provided as well as references to some useful/interesting books.
The Ring programming language version 1.8 book - Part 50 of 202Mahmoud Samir Fayed
The Page class contains methods for generating HTML elements and adding content to web pages. It includes methods for common elements like headings, paragraphs, links, forms, tables, and more. Each method accepts a parameter that allows setting attributes of the element through a list. This allows generating HTML elements with customized attributes in a simple way.
10 Insightful Quotes On Designing A Better Customer ExperienceYuan Wang
In an ever-changing landscape of one digital disruption after another, companies and organisations are looking for new ways to understand their target markets and engage them better. Increasingly they invest in user experience (UX) and customer experience design (CX) capabilities by working with a specialist UX agency or developing their own UX lab. Some UX practitioners are touting leaner and faster ways of developing customer-centric products and services, via methodologies such as guerilla research, rapid prototyping and Agile UX. Others seek innovation and fulfilment by spending more time in research, being more inclusive, and designing for social goods.
Experience is more than just an interface. It is a relationship, as well as a series of touch points between your brand and your customer. Here are our top 10 highlights and takeaways from the recent UX Australia conference to help you transform your customer experience design.
For full article, continue reading at https://yump.com.au/10-ways-supercharge-customer-experience-design/
http://inarocket.com
Learn BEM fundamentals as fast as possible. What is BEM (Block, element, modifier), BEM syntax, how it works with a real example, etc.
How to Build a Dynamic Social Media PlanPost Planner
Stop guessing and wasting your time on networks and strategies that don’t work!
Join Rebekah Radice and Katie Lance to learn how to optimize your social networks, the best kept secrets for hot content, top time management tools, and much more!
Watch the replay here: bit.ly/socialmedia-plan
The document discusses how personalization and dynamic content are becoming increasingly important on websites. It notes that 52% of marketers see content personalization as critical and 75% of consumers like it when brands personalize their content. However, personalization can create issues for search engine optimization as dynamic URLs and content are more difficult for search engines to index than static pages. The document provides tips for SEOs to help address these personalization and SEO challenges, such as using static URLs when possible and submitting accurate sitemaps.
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
How can we take UX and Data Storytelling out of the tech context and use them to change the way government behaves?
Showcasing the truth is the highest goal of data storytelling. Because the design of a chart can affect the interpretation of data in a major way, one must wield visual tools with care and deliberation. Using quantitative facts to evoke an emotional response is best achieved with the combination of UX and data storytelling.
This document summarizes a study of CEO succession events among the largest 100 U.S. corporations between 2005-2015. The study analyzed executives who were passed over for the CEO role ("succession losers") and their subsequent careers. It found that 74% of passed over executives left their companies, with 30% eventually becoming CEOs elsewhere. However, companies led by succession losers saw average stock price declines of 13% over 3 years, compared to gains for companies whose CEO selections remained unchanged. The findings suggest that boards generally identify the most qualified CEO candidates, though differences between internal and external hires complicate comparisons.
The document discusses functional programming techniques for refactoring an imperative program that calculates the sum of squares of even numbers up to a given maximum. It shows how to decompose the program into pure, testable functions using recursion and higher-order functions. This makes the program more reusable, composable and easier to test compared to the original mutable, statement-based implementation.
Functional Programming for OO Programmers (part 2)Calvin Cheng
Code examples demonstrating Functional Programming concepts, with JavaScript and Haskell.
Part 1 can be found here - http://www.slideshare.net/calvinchengx/functional-programming-part01
Source code can be found here - http://github.com/calvinchengx/learnhaskell
Let me know if you spot any errors! Thank you! :-)
This document provides an introduction to the Haskell programming language. It discusses Haskell's features such as being purely functional, lazily evaluated, statically typed, and supporting currying. It also covers Haskell concepts like functions as first-class citizens, pattern matching, monads, and how Haskell avoids side effects through referential transparency and purity. Examples are given for many of these features to illustrate how they work.
This document discusses various Ruby array and string methods like capitalize, each_char, map, sample, shuffle, zip, and more. Code snippets demonstrate how to use these methods on arrays and strings in Ruby. The document also discusses using Node.js and IRB to test Ruby code snippets and the potential to write tests for Ruby code using a BDD style.
The document contains code examples demonstrating various Scala programming concepts such as functions, pattern matching, traits, actors and more. It also includes links to online resources for learning Scala.
This document discusses monads and continuations in functional programming. It provides examples of using monads like Option and List to handle failure in sequences of operations. It also discusses delimited continuations as a low-level control flow primitive that can implement exceptions, concurrency, and suspensions. The document proposes using monads to pass implicit state through programs by wrapping computations in a state transformer (ST) monad.
Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive." This session is an introduction of Scala for Java developers.
Presentation & Fetured Video Included.
The document summarizes Scala, a functional programming language that runs on the Java Virtual Machine (JVM). It discusses Scala's core features like being object-oriented, type inference, and support for functional programming with immutable data structures and passing functions as parameters. It also provides examples of using Scala collections like List and Array, and functions like map, filter, flatMap, and foldLeft/reduceLeft. Finally, it demonstrates using Scala for domain-specific languages and shows examples of defining DSLs for querying and generating JavaScript.
Scala - where objects and functions meetMario Fusco
The document provides an overview of a two-day training course on Scala that covers topics like object orientation, functional programming, pattern matching, generics, traits, case classes, tuples, collections, concurrency, options and monads. The course aims to show how Scala combines object-oriented and functional programming approaches and provides examples of commonly used Scala features like classes, traits, pattern matching, generics and collections.
The document discusses Kotlin collections and aggregate operations on collections. It explains that Kotlin collections can be mutable or immutable, and by default collections are immutable unless specified as mutable. It then covers various aggregate operations that can be performed on collections like any, all, count, fold, foldRight, forEach, max, min, none etc and provides code examples for each operation.
This document provides 7 habits for writing more functional Swift code. It discusses avoiding mutability and for-loops in favor of map, filter and reduce functions. It also covers being lazy, currying functions, writing domain-specific languages, and thinking about code in terms of data and functions rather than objects.
This document provides a summary of new features in JavaScript, including let/const block scoping, arrow functions, template strings, classes, generators, async/await, and more. It explains each feature in 1-3 sentences and includes code examples.
Here are the steps to solve this problem:
1. Convert both lists of numbers to sets:
set1 = {11, 2, 3, 4, 15, 6, 7, 8, 9, 10}
set2 = {15, 2, 3, 4, 15, 6}
2. Find the intersection of the two sets:
intersection = set1.intersection(set2)
3. The number of elements in the intersection is the number of similar elements:
similarity = len(intersection)
4. Print the result:
print(similarity)
The similarity between the two sets is 4, since they both contain the elements {2, 3, 4, 15}.
The document introduces Scala and provides an overview of Scala basics including variables, functions, objects, classes, traits, pattern matching, for-comprehensions and more. It also discusses Scala's capabilities for generic programming, lazy evaluation, and integration with Java. Examples are provided throughout to demonstrate Scala concepts.
Function Programming in Scala.
A lot of my examples here comes from the book
Functional programming in Scala By Paul Chiusano and Rúnar Bjarnason, It is a good book, buy it.
Intro to Functional Programming Workshop (code4lib)Will Kurt
This document provides an introduction to functional programming concepts like recursion, higher-order functions, and currying using JavaScript and Haskell examples. It begins with an overview of functional programming and then presents exercises involving lists, recursion, and functions like map, filter, and fold that build up skills with these concepts over multiple sections.
This document provides an overview of using R for financial modeling. It covers basic R commands for calculations, vectors, matrices, lists, data frames, and importing/exporting data. Graphical functions like plots, bar plots, pie charts, and boxplots are demonstrated. Advanced topics discussed include distributions, parameter estimation, correlations, linear and nonlinear regression, technical analysis packages, and practical exercises involving financial data analysis and modeling.
The document discusses programming with futures in Java and Scala. It introduces futures in Java 8 using CompletableFuture and shows how they allow composing asynchronous operations without blocking threads. It then discusses how streams and futures in Java 8 share similar composition concepts using thenApply and thenCompose. The talk moves on to introduce more abstract concepts from category theory - monads, foldables and monoids. It shows how these concepts can be implemented for futures and lists to provide generic sequencing and folding of asynchronous and synchronous operations in a precise way.
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Chris Swan
Have you noticed the OpenSSF Scorecard badges on the official Dart and Flutter repos? It's Google's way of showing that they care about security. Practices such as pinning dependencies, branch protection, required reviews, continuous integration tests etc. are measured to provide a score and accompanying badge.
You can do the same for your projects, and this presentation will show you how, with an emphasis on the unique challenges that come up when working with Dart and Flutter.
The session will provide a walkthrough of the steps involved in securing a first repository, and then what it takes to repeat that process across an organization with multiple repos. It will also look at the ongoing maintenance involved once scorecards have been implemented, and how aspects of that maintenance can be better automated to minimize toil.
Implementations of Fused Deposition Modeling in real worldEmerging Tech
The presentation showcases the diverse real-world applications of Fused Deposition Modeling (FDM) across multiple industries:
1. **Manufacturing**: FDM is utilized in manufacturing for rapid prototyping, creating custom tools and fixtures, and producing functional end-use parts. Companies leverage its cost-effectiveness and flexibility to streamline production processes.
2. **Medical**: In the medical field, FDM is used to create patient-specific anatomical models, surgical guides, and prosthetics. Its ability to produce precise and biocompatible parts supports advancements in personalized healthcare solutions.
3. **Education**: FDM plays a crucial role in education by enabling students to learn about design and engineering through hands-on 3D printing projects. It promotes innovation and practical skill development in STEM disciplines.
4. **Science**: Researchers use FDM to prototype equipment for scientific experiments, build custom laboratory tools, and create models for visualization and testing purposes. It facilitates rapid iteration and customization in scientific endeavors.
5. **Automotive**: Automotive manufacturers employ FDM for prototyping vehicle components, tooling for assembly lines, and customized parts. It speeds up the design validation process and enhances efficiency in automotive engineering.
6. **Consumer Electronics**: FDM is utilized in consumer electronics for designing and prototyping product enclosures, casings, and internal components. It enables rapid iteration and customization to meet evolving consumer demands.
7. **Robotics**: Robotics engineers leverage FDM to prototype robot parts, create lightweight and durable components, and customize robot designs for specific applications. It supports innovation and optimization in robotic systems.
8. **Aerospace**: In aerospace, FDM is used to manufacture lightweight parts, complex geometries, and prototypes of aircraft components. It contributes to cost reduction, faster production cycles, and weight savings in aerospace engineering.
9. **Architecture**: Architects utilize FDM for creating detailed architectural models, prototypes of building components, and intricate designs. It aids in visualizing concepts, testing structural integrity, and communicating design ideas effectively.
Each industry example demonstrates how FDM enhances innovation, accelerates product development, and addresses specific challenges through advanced manufacturing capabilities.
Are you interested in learning about creating an attractive website? Here it is! Take part in the challenge that will broaden your knowledge about creating cool websites! Don't miss this opportunity, only in "Redesign Challenge"!
How to Avoid Learning the Linux-Kernel Memory ModelScyllaDB
The Linux-kernel memory model (LKMM) is a powerful tool for developing highly concurrent Linux-kernel code, but it also has a steep learning curve. Wouldn't it be great to get most of LKMM's benefits without the learning curve?
This talk will describe how to do exactly that by using the standard Linux-kernel APIs (locking, reference counting, RCU) along with a simple rules of thumb, thus gaining most of LKMM's power with less learning. And the full LKMM is always there when you need it!
The DealBook is our annual overview of the Ukrainian tech investment industry. This edition comprehensively covers the full year 2023 and the first deals of 2024.
GDG Cloud Southlake #34: Neatsun Ziv: Automating AppsecJames Anderson
The lecture titled "Automating AppSec" delves into the critical challenges associated with manual application security (AppSec) processes and outlines strategic approaches for incorporating automation to enhance efficiency, accuracy, and scalability. The lecture is structured to highlight the inherent difficulties in traditional AppSec practices, emphasizing the labor-intensive triage of issues, the complexity of identifying responsible owners for security flaws, and the challenges of implementing security checks within CI/CD pipelines. Furthermore, it provides actionable insights on automating these processes to not only mitigate these pains but also to enable a more proactive and scalable security posture within development cycles.
The Pains of Manual AppSec:
This section will explore the time-consuming and error-prone nature of manually triaging security issues, including the difficulty of prioritizing vulnerabilities based on their actual risk to the organization. It will also discuss the challenges in determining ownership for remediation tasks, a process often complicated by cross-functional teams and microservices architectures. Additionally, the inefficiencies of manual checks within CI/CD gates will be examined, highlighting how they can delay deployments and introduce security risks.
Automating CI/CD Gates:
Here, the focus shifts to the automation of security within the CI/CD pipelines. The lecture will cover methods to seamlessly integrate security tools that automatically scan for vulnerabilities as part of the build process, thereby ensuring that security is a core component of the development lifecycle. Strategies for configuring automated gates that can block or flag builds based on the severity of detected issues will be discussed, ensuring that only secure code progresses through the pipeline.
Triaging Issues with Automation:
This segment addresses how automation can be leveraged to intelligently triage and prioritize security issues. It will cover technologies and methodologies for automatically assessing the context and potential impact of vulnerabilities, facilitating quicker and more accurate decision-making. The use of automated alerting and reporting mechanisms to ensure the right stakeholders are informed in a timely manner will also be discussed.
Identifying Ownership Automatically:
Automating the process of identifying who owns the responsibility for fixing specific security issues is critical for efficient remediation. This part of the lecture will explore tools and practices for mapping vulnerabilities to code owners, leveraging version control and project management tools.
Three Tips to Scale the Shift Left Program:
Finally, the lecture will offer three practical tips for organizations looking to scale their Shift Left security programs. These will include recommendations on fostering a security culture within development teams, employing DevSecOps principles to integrate security throughout the development
Kief Morris rethinks the infrastructure code delivery lifecycle, advocating for a shift towards composable infrastructure systems. We should shift to designing around deployable components rather than code modules, use more useful levels of abstraction, and drive design and deployment from applications rather than bottom-up, monolithic architecture and delivery.
How Netflix Builds High Performance Applications at Global ScaleScyllaDB
We all want to build applications that are blazingly fast. We also want to scale them to users all over the world. Can the two happen together? Can users in the slowest of environments also get a fast experience? Learn how we do this at Netflix: how we understand every user's needs and preferences and build high performance applications that work for every user, every time.
Coordinate Systems in FME 101 - Webinar SlidesSafe Software
If you’ve ever had to analyze a map or GPS data, chances are you’ve encountered and even worked with coordinate systems. As historical data continually updates through GPS, understanding coordinate systems is increasingly crucial. However, not everyone knows why they exist or how to effectively use them for data-driven insights.
During this webinar, you’ll learn exactly what coordinate systems are and how you can use FME to maintain and transform your data’s coordinate systems in an easy-to-digest way, accurately representing the geographical space that it exists within. During this webinar, you will have the chance to:
- Enhance Your Understanding: Gain a clear overview of what coordinate systems are and their value
- Learn Practical Applications: Why we need datams and projections, plus units between coordinate systems
- Maximize with FME: Understand how FME handles coordinate systems, including a brief summary of the 3 main reprojectors
- Custom Coordinate Systems: Learn how to work with FME and coordinate systems beyond what is natively supported
- Look Ahead: Gain insights into where FME is headed with coordinate systems in the future
Don’t miss the opportunity to improve the value you receive from your coordinate system data, ultimately allowing you to streamline your data analysis and maximize your time. See you there!
20240702 QFM021 Machine Intelligence Reading List June 2024
関数潮流(Function Tendency)
76. js> function add2(x) { return x + 2; }
js> add2(5);
7
js> var f = function(x) { return x + 2; }
js> f(8);
10
js> (function(x) { return x + 2; })(9)
11
77. js> function add2(x) { return x + 2; }
js> add2(5);
7
js> var f = function(x) { return x + 2; }
js> f(8);
10
js> (function(x) { return x + 2; })(9)
11
78. js> function add2(x) { return x + 2; }
js> add2(5);
7
js> var f = function(x) { return x + 2; }
js> f(8);
10
js> (function(x) { return x + 2; })(9)
11
79. js> function add2(x) { return x + 2; }
js> add2(5);
7
js> var f = function(x) { return x + 2; }
js> f(8);
10
js> (function(x) { return x + 2; })(9)
11
80. js> function add2(x) { return x + 2; }
js> add2(5);
7
js> var f = function(x) { return x + 2; }
js> f(8);
10
js> (function(x) { return x + 2; })(9)
11
81. Func<int, int> f = (x) => x + 2;
var f = function(x) { return x + 2; }
f = lambda x: x + 2;
f = x -> x + 2
(fset 'f (lambda (x) (+ x 2)))
87. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
88. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
89. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
90. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
91. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
92. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
93. Func<string, string>
foo(Func<DateTime, string> f) {
return
x => x.ToUpper() + " "
+ f(DateTime.Today);
}
Func<DateTime, string> d =
x => x.Year + "/" + x.Month;
Func<string, string> c = foo(d);
string result = c("oblove");
“OBLOVE 2011/7”
104. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
105. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
106. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
107. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
108. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
109. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
110. int sum(int acc, IEnumerable<int> list) {
if (!list.Any()) {
return acc;
}
int head = list.First();
return sum(acc + head, list.Skip(1));
}
List<int> ls = new List<int> { 3, 5, 8 };
int result = sum(0, ls);
132. >>> [x for x in [1, 2, 3, 4, 5]
if (x % 2 != 0)]
[1, 3, 5]
var l = from x
in new List<int> { 1, 2, 3, 4, 5 }
where x % 2 != 0
select x;
133. >>> [x * 2 for x in [1, 2, 3, 4, 5]
if (x % 2 != 0)]
[2, 6, 10]
var l = from x
in new List<int> { 1, 2, 3, 4, 5 }
where x % 2 != 0
select x * 2;
135. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
136. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
137. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
138. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
139. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
140. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
141. def cor(f):
i = 0
while True:
i = f(i)
yield i
l = cor(lambda x: x + 4)
[l.next() for x in range(0, 3)]
[4, 8, 12]
142. IEnumerable<int> cor(Func<int, int> f) {
int i = 0;
while (true) {
i = f(i);
yield return i;
}
}
var li = cor(x => x + 4);
var ls = from x in li.Take(3)
select "<" + x.ToString() + ">";
[“<4>”, “<8>”, “<12>”]