Showing posts with label computer science. Show all posts
Showing posts with label computer science. Show all posts

Thursday, September 18, 2014

Functional Programming and Math, What you need to know

Functional programming can be better understood if one understands functional composition concepts that are often taught in precalculus and college algebra. A mathematical functional composition problem requires at least two functions. In a two function problem, the result obtained from evaluating one function is substituted into the dependent variable of another function to obtain the final output. 

For example,  given the two functions

f(x) = x + 2 

g(x) = 3x 

find the composition of g(f(2)) means to first evaluate f(2) and then substitute that value into x of g(x) to obtain the final result. 

Since f(2) = 2 + 2 = 4

Substituting 4 into x in the g(x) equation yields

g(4) = 3*4 = 12 

so g(f(2)) = 12 

Functional composition can be extended to 3 or as many functions as you like. Simply take the output of the function and feed it into the independent variable of another function. Then take that output and feed it into another function. 

Functional programming works along the same math based mindset. Functional programming takes an output of a function, such as a JavaScript function and feeds it  into another function You can chain together as many JavaScript functions as you like.  

Other concepts such as recursion also come into play in functional programming. Recursion, is slightly different than functional composition. Instead of feeding the output of the function into the independent variable of another function, you feed the output of one function back into the independent variable of  the same function. 

Posted By: Mark Stansberry, www.bookmarktutorin.com on Sept 18 2014

BookMarkTutoring.com offers onSite, onCall, onLine and inPerson tutoring in math, science, computer programming and graphic design.  





Sunday, September 29, 2013

Learn Scala Programming: Download, Installation and Programming

At this site, scala-lang.org you can learn Scala from beginning to end.  You can download Scala at the site. The site also includes links to the Scala API documentation, an online Scala interpreter, Scala cheat sheets and more.

http://www.scala-lang.org/documentation/

This site, matt.might.net,  includes Scala code examples that beginners use to become familiar with Scala.

Learn Code Examples Link: http://matt.might.net/articles/learning-scala-in-small-bites/


This sit, learnxinyminutes,  includes a number of Scala code examples.   Methods and statements in working code examples include println, print, variable declarations with the Val statement, the REPL environment, mathematical operations, boolean operations, string operations, functions, objects, class declaration, class extension, pattern matching, regular expressions, for and do while loops, match statements, conditional statements such as case switch, strings, and importable sub packages such as immutable as well as use of the object Application entry point.

Learn Code Example Link: http://learnxinyminutes.com/docs/scala/


This site, tutorialspoint.com, includes complete guide to programming Scala. Includes detailed code explanations with working code. Scala Tutorials include overview, environmental setup, data types, variables, access modifiers, operators, if else statements, loops, functions, closures, strings, arrays, collections, classes and objects, traits, pattern matching, regular expressions, exception handling, extractors, and file I/O statements for reading and writing files. Also includes a scala quick guide, and a resource section.


http://www.tutorialspoint.com/scala/index.htm

This site, https://www.coursera.org/course/proglfun, offers a free 7  week course in Scala, with a focus on the basics of functional programming. You have to sign up with Coursera to take the course. The course, Functional Programming Principles in Scala, with instructor Martin Odersky, covers programming paradigms, functional programming, an overview of the Scala programming language, the definition and use of functions, recursion, and non-terminating functions, reasoning by induction, the definition and use of immutable objects, inheritance, dynamic binding, data types, pattern matching, lists, collections, combinatorial search and lazy evaluation.  online.