Posts

Showing posts with the label india

Exploring Common Lisp: Project Euler Number 8 in Common Lisp (Neophyte Version)

There isn't really much I can add about this example. The goal is to find the largest product of any consecutive digits given a 1000 digit number. I implemented the first approach that came to mind; I went with a large loop to iterate through the 1000 digits and then an inner loop to extract that digits we are going to use in our calculation. The key built-in lisp functions are "loop" and "reduce". If you are not used to a lisp programming language, a C version of this solution is provided. ;; ;; euler8.lisp (modify to find the "correct" solution) ;; Find the greatest product of five ;; consecutive digits in the 1000-digit number ;; ;; [1] http://www.unixuser.org/~euske/doc/cl/loop.html ( defparameter *large-num* "73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843" ) ( defun find-great-product () "Use reduce to find the product of a list of 5 digits out of the larger 1...

Revisiting Self Replicating Molecules in an Artificial Chemistry Automaton

Image
Introduction   This blog entry describes an artificial chemistry simulation implemented through a cellular automaton. We show that basic rules can be used to produce complex behavior through simulated artificial chemical reactions. The chemical simulation exists on a fixed size two dimensional grid of cells.  Each active cell is represented by an artificial atom element, these atoms may collide with other atoms to produce a chemical reaction.  Strong chemical bonds will form if the chemical reaction is allowed by system.  Clusters of strong bonded atoms form molecule strings.   We show that self replicating molecule string patterns emerge from the artificial simulation.  This analysis is based on Timothy Hutton's artificial chemistry model from Squirm3.  It it is a basic model but a necessary step for analyzing and recreating similar natural systems.  Self-replication and self-organization is fundamental to all biological life. ...

Declarative programming introduction

"Haskell is a very elegant language, and the functional nature of it makes it a beautiful glue language... because the nature of Haskell as a language can make things clearer than many other programming languages" -- Mark C. Chu-Carroll of the ScienceBlogs "Haskell is a declarative language in that the program can be treated as a statement of facts, rather than as a set of commands that are sequenced in time" -- cdsmith Declarative programming is a programming paradigm that encourages that the programming logic describes what the program will do as opposed to how it will do it. Also, you don't define your programming logic in a sequence of steps like you normally would using an imperative style programming. Functional programming is considered declarative programming. With the imperative programming paradigm, one might do the following to reach a desired state. In Java (imperative style): final SavingsAccount savings = new SavingsAccount (); // ...