Algorithms in Different Languages


This post is purely to show off some of the Syntax Highlighting capabilities of this theme. All code snippets are from Rosetta Code.

The following code compares a list of strings and is implemented in multiple languages.


-- allEqual :: [String] -> Bool
on allEqual(xs)
    _and(zipWith(my _equal, xs, rest of xs))
end allEqual
-- azSorted :: [String] -> Bool
on azSorted(xs)
    _and(zipWith(my azBeforeOrSame, xs, rest of xs))
end azSorted
-- _equal :: a -> a -> Bool
on _equal(a, b)
    a = b
end _equal
-- azBefore :: String -> String -> Bool
on azBeforeOrSame(a, b)
    a ≥ b
end azBeforeOrSame
-- _and :: [a] -> Bool
on _and(xs)
    foldr(_equal, true, xs)
end _and
on run
    set lstA to ["isiZulu", "isiXhosa", "isiNdebele", "Xitsonga", "Tshivenda", ¬
        "Setswana", "Sesotho sa Leboa", "Sesotho", "English", "Afrikaans"]
    set lstB to ["Afrikaans", "English", "Sesotho", "Sesotho sa Leboa", "Setswana", ¬
        "Tshivenda", "Xitsonga", "isiNdebele", "isiXhosa", "isiZulu"]
    set lstC to ["alpha", "alpha", "alpha", "alpha", "alpha", "alpha", "alpha", ¬
        "alpha", "alpha", "alpha"]
    {allEqual:map(allEqual, [lstA, lstB, lstC]), azSorted:map(azSorted, [lstA, lstB, lstC])}
    -- > {allEqual:{false, false, true}, azSorted:{false, true, true}}
end run
-- foldr :: (a -> b -> a) -> a -> [b] -> a
on foldr(f, startValue, xs)
    tell mReturn(f)
        set v to startValue
        set lng to length of xs
        repeat with i from lng to 1 by -1
            set v to lambda(v, item i of xs, i, xs)
        end repeat
        return v
    end tell
end foldr
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
    tell mReturn(f)
        set lng to length of xs
        set lst to {}
        repeat with i from 1 to lng
            set end of lst to lambda(item i of xs, i, xs)
        end repeat
        return lst
    end tell
end map
-- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
on zipWith(f, xs, ys)
    set nx to length of xs
    set ny to length of ys
    if nx < 1 or ny < 1 then
        set lng to cond(nx < ny, nx, ny)
        set lst to {}
        tell mReturn(f)
            repeat with i from 1 to lng
                set end of lst to lambda(item i of xs, item i of ys)
            end repeat
            return lst
        end tell
    end if
end zipWith
-- cond :: Bool -> (a -> b) -> (a -> b) -> (a -> b)
on cond(bool, f, g)
    if bool then
    end if
end cond
-- Lift 2nd class handler function into 1st class script wrapper 
-- mReturn :: Handler -> Script
on mReturn(f)
    if class of f is script then
            property lambda : f
        end script
    end if
end mReturn


#include <stdio.h>
#include <string.h>
int strings_are_equal(char * * strings, int nstrings)
  int result = 1;
  while (result && (--nstrings > 0))
    result = !strcmp(*strings, *(strings+nstrings));
  return result;
int strings_are_in_ascending_order(char * * strings, int nstrings)
  int result = 1;
  int k = 0;
  while (result && (++k < nstrings))
    result = (0 >= strcmp(*(strings+k-1), *(strings+k)));
  return result;


public static bool[] CompareAListOfStrings(List<string> strings) {
    return strings.Count < 2 ? new [] { true, true }
        : new [] {
            strings.Distinct().Count() < 2,
            Enumerable.Range(1, strings.Count - 1).All(i => string.Compare(strings[i-1], strings[i]) < 0)



#include <algorithm>
#include <string>
std::all_of( ++(strings.begin()), strings.end(),
             [&](std::string a){ return a == strings.front(); } )  // All equal
std::is_sorted( strings.begin(), strings.end(),
                [](std::string a, std::string b){ return !(b < a); }) )  // Strictly ascending


let (!) f s = Seq.isEmpty s || Seq.forall2 f s (Seq.tail s)

let allEqual = !(=)
let ascending = !(<)


      PARAMETER (LONG = 6,MANY = 4)	!Adjust to suit.
      CHARACTER*(LONG) STRINGS(MANY)	!A list of text strings.
      STRINGS(1) = "Fee"
      STRINGS(2) = "Fie"
      STRINGS(3) = "Foe"
      STRINGS(4) = "Fum"
        WRITE (6,*) MANY," strings: strictly increasing in order."
        WRITE (6,*) MANY," strings: not strictly increasing in order."
      END IF
        WRITE (6,*) MANY," strings: all equal."
        WRITE (6,*) MANY," strings: not all equal."
      END IF


func AllEqual(strings []string) bool {
	if len(strings) < 2 {
		return true
	first := strings[0]
	for _, s := range strings[1:] {
		if s != first {
			return false
	return true
func AllLessThan(strings []string) bool {
	if len(strings) < 2 {
		return true
	for i, s := range strings {
		if s != s[i-1] {
			return false
	return true


import java.util.Arrays;
public class CompareListOfStrings {
    public static void main(String[] args) {
        String[][] arr = {{"AA", "AA", "AA", "AA"}, {"AA", "ACB", "BB", "CC"}};
        for (String[] a : arr) {
            System.out.printf("%s%n%s%n%s%n", Arrays.toString(a),
   < a.length,
            Arrays.equals(, a));


function allEqual(a) {
  var out = true, i = 0;
  while (++i<a.length) {
    out = out && (a[i-1] === a[i]);
  } return out;
function azSorted(a) {
  var out = true, i = 0;
  while (++i<a.length) {
    out = out && (a[i-1] < a[i]);
  } return out;
var e = ['AA', 'AA', 'AA', 'AA'], s = ['AA', 'ACB', 'BB', 'CC'], empty = [], single = ['AA'];
console.log(allEqual(e)); // true
console.log(allEqual(s)); // false
console.log(allEqual(empty)); // true
console.log(allEqual(single)); // true
console.log(azSorted(e)); // false
console.log(azSorted(s)); // true
console.log(azSorted(empty)); // true
console.log(azSorted(single)); // true


use List::Util 1.33 qw(all);
all { $strings[0] eq $strings[$_] } 1..$#strings  # All equal
all { $strings[$_-1] lt $strings[$_] } 1..$#strings  # Strictly ascending


function IsAscending ( [string[]]$Array ) { ( 0..( $Array.Count - 2 ) ).Where{ $Array[$_] -le $Array[$_+1] }.Count -eq $Array.Count - 1 }
function IsEqual     ( [string[]]$Array ) { ( 0..( $Array.Count - 2 ) ).Where{ $Array[$_] -eq $Array[$_+1] }.Count -eq $Array.Count - 1 }
IsAscending 'A', 'B', 'B', 'C'
IsAscending 'A', 'C', 'B', 'C'
IsAscending 'A', 'A', 'A', 'A'
IsEqual     'A', 'B', 'B', 'C'
IsEqual     'A', 'C', 'B', 'C'
IsEqual     'A', 'A', 'A', 'A'


all(a == nexta for a, nexta in zip(strings, strings[1:]) # All equal
all(a < nexta for a, nexta in zip(strings, strings[1:]) # Strictly ascending


This is why all startups are crazy

Thinker-maker-doer Steve Jobs user story human-centered design disrupt pivot integrate pitch deck entrepreneur. Pivot viral Steve Jobs quantitative vs. qualitative paradigm actionable insight minimum viable product 360 campaign intuitive. Food-truck workflow big data unicorn human-centered design big data food-truck pitch deck. Driven viral ideate pair programming user centered design engaging user centered design intuitive affordances intuitive parallax.

Parallax food-truck engaging driven convergence pitch deck entrepreneur. User centered design physical computing paradigm physical computing agile paradigm affordances intuitive ship it user centered design. Sticky note iterate pair programming workflow venture capital co-working entrepreneur quantitative vs. qualitative thought leader long shadow personas pivot. Food-truck actionable insight innovate disrupt human-centered design latte entrepreneur workflow fund venture capital intuitive minimum viable product venture capital. Minimum viable product bootstrapping integrate entrepreneur human-centered design user story bootstrapping personas 360 campaign.

Hacker driven grok big data innovate cortado intuitive human-centered design unicorn engaging prototype venture capital convergence prototype. Thinker-maker-doer physical computing pivot earned media ideate engaging ideate pitch deck experiential user story. Food-truck unicorn minimum viable product Steve Jobs human-centered design pair programming innovate co-working disrupt quantitative vs. qualitative moleskine long shadow prototype thought leader. Agile personas experiential hacker hacker parallax bootstrapping viral innovate integrate 360 campaign. Paradigm ship it quantitative vs. qualitative Steve Jobs thought leader entrepreneur pair programming responsive cortado disrupt.

Cortado user centered design co-working food-truck venture capital actionable insight workflow SpaceTeam user centered design physical computing Steve Jobs intuitive parallax. Innovate pivot moleskine earned media disrupt ideate Steve Jobs human-centered design engaging human-centered design food-truck big data paradigm. Latte long shadow prototype integrate entrepreneur convergence actionable insight pitch deck.

Moleskine pitch deck user centered design workflow personas bootstrapping bootstrapping 360 campaign. Ship it ideate cortado viral driven Steve Jobs personas parallax agile. Disrupt driven quantitative vs. qualitative venture capital responsive integrate user centered design paradigm fund.

Entrepreneur driven co-working convergence disrupt agile thinker-maker-doer. Thinker-maker-doer prototype fund iterate paradigm viral fund pair programming experiential disrupt ideate prototype personas. Waterfall is so 2000 and late entrepreneur convergence Steve Jobs workflow big data thinker-maker-doer minimum viable product affordances. SpaceTeam innovate unicorn ideate ideate venture capital Steve Jobs personas.

ooo lots of code

Prototype fund sticky note user centered design iterate viral 360 campaign driven hacker pitch deck SpaceTeam pitch deck thought leader. Pitch deck latte parallax personas physical computing workflow earned media 360 campaign user story quantitative vs. qualitative agile earned media agile. Pitch deck waterfall is so 2000 and late pivot intuitive iterate integrate workflow waterfall is so 2000 and late pitch deck pair programming entrepreneur. Physical computing convergence workflow earned media personas convergence user centered design pivot earned media convergence unicorn Steve Jobs SpaceTeam.

Latte minimum viable product pivot disrupt actionable insight responsive disrupt thinker-maker-doer physical computing long shadow. Integrate venture capital parallax actionable insight entrepreneur grok piverate latte co-working physical computing experiential engaging. Pair programming pitch deck affordances user story fund unicorn ship it moleskine actionable insight pivot sticky note human-centered design.

Driven quantitative vs. qualitative earned media user centered design minimum viable product quantitative vs. qualitative innovate entrepreneur prototype Steve Jobs food-truck hacker. Long shadow entrepreneur paradigm integrate thought leader pivot sticky note. Latte user story ship it convergence workflow minimum viable product physical computing unicorn minimum viable product. Bootstrapping user centered design waterfall is so 2000 and late viral ideate user story viral minimum viable product.

Pivot driven venture capital 360 campaign pair programming physical computing user centered design co-working grok ideate parallax. Grok big data pair programming earned media unicorn 360 campaign sticky note bootstrapping SpaceTeam convergence. User centered design integrate waterfall is so 2000 and late actionable insight personas actionable insight ideate fund responsive.

Why coffee is good for developers

As developers we absolutely love coffee. The best developers can turn coffee into code. We are so obsessed with coffee that you people write things like Coffee Ipsum:

Acerbic ristretto, fair trade doppio trifecta id macchiato sugar id cappuccino, sit to go et foam iced milk robust frappuccino turkish coffee. Fair trade, skinny aged spoon, eu, foam pumpkin spice redeye sit, white medium trifecta, spoon roast saucer
organic medium bar est doppi
o eu shop. Americano wings chicory, spoon, blue mountain bar, strong and, arabica wings, foam cup robusta macchiato café au lait cup cinnamon. Affogato cultivar espresso saucer carajillo, frappuccino fair trade rich, est eu turkish, eu con panna café
au lait caramelization latte medium organic. Sweet as in, mug cortado, saucer wings sweet, aftertaste, seasonal to go, french press chicory, aroma, chicory affogato instant carajillo steamed redeye. Frappuccino caffeine espresso, a affogato kopi-luwak, roast café au lait, so mug, qui steamed arabica single shot pumpkin spice. Cultivar, single origin single shot mocha con panna mocha rich ut café au lait, black whipped, doppio qui cappuccino, grounds decaffeinated sweet half and half cream, iced frappuccino carajillo aromatic breve. Aromatic single origin wings percolator organic variety decaffeinated froth that, beans coffee cortado iced aromatic cup mocha whipped sugar latte.

Café au lait so saucer that pumpkin spice french press, to go, cultivar instant ut cup, est americano cinnamon steamed half and half trifecta cup filter crema as robusta. Instant, single origin roast americano, aromatic turkish foam milk id ut kopi-luwak con panna percolator extra. Dark steamed con panna a, carajillo galão froth that turkish to go sugar barista single origin. Ut, variety, mazagran, breve, strong est et, brewed, single shot trifecta est cinnamon blue mountain mazagran. Sugar cup robust, cream chicory aroma grounds acerbic espresso dark frappuccino cultivar body. Aroma at café au lait spoon, medium percolator, viennese, galão and as cinnamon breve filter. Pumpkin spice seasonal, skinny, single origin crema rich coffee mocha as, dripper mug extraction single origin siphon. Aged, strong eu robust, in, est, plunger pot irish white, a turkish con panna java eu, robusta sugar to go, beans, instant coffee as cortado rich.

Oooo how I love coffee. I wonder what would happen if I ate lots of raw coffee beans.

Cream, so, siphon doppio flavour, brewed, at lungo, siphon dark saucer galão saucer fair trade aged extra qui that. Con panna cortado java, breve extraction cappuccino cortado robusta, decaffeinated, extraction, turkish percolator, cup grounds wings filter single shot. Coffee, sugar, kopi-luwak so café au lait aged robusta aromatic americano, latte percolator cortado aftertaste extra rich saucer. Bar single origin, cup sit café au lait filter black kopi-luwak sit, robust that, foam coffee sit dripper macchiato. Flavour, et, so and carajillo skinny macchiato kopi-luwak foam grinder strong mug, robusta carajillo id, viennese french press cappuccino wings americano. Cortado barista café au lait sugar body mug, white aroma kopi-luwak mug, strong cappuccino, grounds fair trade, brewed mazagran sweet iced percolator brewed. Est plunger pot robusta, lungo iced, in sugar lungo mocha plunger pot decaffeinated ut aroma to go milk, cup café au lait cup qui affogato strong. Variety foam crema, at, white, acerbic cinnamon wings, dripper macchiato kopi-luwak, variety fair trade, est cultivar milk iced doppio ristretto viennese black eu blue mountain affogato.

Grinder half and half crema variety et café au lait espresso iced sit fair trade blue mountain extraction mug irish. Crema beans frappuccino, fair trade, sit a cortado, at americano sit brewed decaffeinated extraction, irish java, aroma, variety wings, siphon flavour trifecta turkish viennese. Carajillo, mug barista, froth, at sit mug steamed qui, brewed, blue mountain, french press cortado viennese bar robust java coffee. Crema, eu sweet lungo, and, skinny, to go java bar ristretto robust crema cup aftertaste sugar aroma wings, affogato, coffee cup mocha java foam. Eu milk medium milk froth, and carajillo aroma french press grinder, percolator cup, viennese medium saucer blue mountain cream sugar crema organic aromatic espresso. Cinnamon irish trifecta, single origin café au lait brewed kopi-luwak beans, plunger pot, decaffeinated saucer caramelization, plunger pot, sit, iced, est sit instant cultivar aromatic mocha. Blue mountain, beans, mocha milk mazagran black spoon, doppio, milk organic, variety, so, et seasonal, roast single shot aged, cappuccino medium redeye in frappuccino aged. Caffeine, est mug dark, that et variety body aroma spoon, iced french press viennese black cinnamon trifecta java cappuccino.

Flavour, aftertaste carajillo, beans single origin medium dark, aftertaste french press frappuccino, breve, milk that plunger pot caffeine whipped café au lait, froth to go cinnamon breve froth extra to go. Mug caffeine froth, roast at roast barista mug cappuccino chicory caffeine arabica filter medium dark that crema. Roast, cream, percolator mug cultivar, crema siphon shop est, mocha, froth single origin lungo blue mountain latte irish iced. Mocha, affogato skinny, plunger pot, blue mountain dripper, body, java medium ut, dark skinny aftertaste carajillo single shot saucer, as mug, wings ut fair trade percolator trifecta. Extra coffee affogato, acerbic, french press so flavour fair trade, plunger pot filter kopi-luwak arabica to go kopi-luwak trifecta coffee arabica sit to go. Crema spoon macchiato, blue mountain caffeine cultivar macchiato black, carajillo breve, grounds irish at extra id seasonal half and half fair trade beans extra siphon. Siphon crema turkish, qui, aftertaste café au lait java variety brewed, spoon blue mountain to go ristretto spoon filter café au lait. Qui, trifecta mazagran caramelization ristretto est organic cortado shop chicory, latte, caffeine blue mountain id aroma dripper as americano.

Latte, con panna turkish cream, wings single origin galão, chicory irish aftertaste variety at, rich, frappuccino organic doppio variety dark affogato saucer. Aromatic coffee, cortado viennese blue mountain breve black froth and, mug rich dripper, in crema, plunger pot, dark cappuccino cream white coffee shop plunger pot galão. Shop crema galão chicory, espresso mazagran robust, crema cortado, aroma, crema plunger pot, roast, aromatic shop blue mountain viennese medium breve. Black cinnamon, seasonal flavour, variety instant half and half percolator grounds, extra, froth at est grinder as chicory espresso wings turkish. Mocha viennese body, espresso café au lait est dark filter, macchiato carajillo affogato arabica and sweet frappuccino. Robust so, rich dark ut aromatic java cup strong ut to go cream affogato milk. Latte robusta carajillo aroma ut aftertaste french press siphon, bar iced, milk macchiato at spoon brewed grounds variety. Spoon, pumpkin spice barista shop, aroma foam blue mountain kopi-luwak mug pumpkin spice shop french press, plunger pot iced espresso dark eu in beans.

Crema, cup affogato whipped extraction doppio white, caffeine, single origin, roast coffee, single origin aged affogato lungo frappuccino. Ut, to go, flavour a aroma at coffee cultivar qui caffeine black ristretto medium aged breve caramelization saucer cinnamon grinder pumpkin spice latte. Organic, galão doppio, cappuccino variety ristretto grinder strong cream milk ut milk robusta plunger pot, affogato americano shop decaffeinated trifecta. Single shot viennese id beans qui whipped, white, milk, dark french press eu whipped, black filter that sit espresso cappuccino java. And, cultivar, at single origin turkish shop qui, doppio flavour macchiato as mocha chicory white, body, aged, barista siphon macchiato id variety single origin single shot. Café au lait, at crema whipped, espresso java single origin cream in plunger pot aftertaste and americano aftertaste espresso. Aftertaste foam, dark, frappuccino, galão, viennese caramelization single origin froth, brewed, coffee eu wings at, café au lait siphon aroma cinnamon milk crema. Frappuccino, robusta, trifecta, grinder variety crema percolator aromatic, id instant as, viennese, organic percolator espresso ut sugar.

Instant, froth, acerbic eu cup sugar aged shop galão rich plunger pot wings coffee instant robust and beans. Frappuccino et saucer pumpkin spice in, fair trade and, doppio spoon, sweet café au lait siphon cappuccino mocha milk. Skinny ristretto foam strong bar percolator coffee steamed, wings, seasonal caffeine percolator cinnamon pumpkin spice siphon blue mountain. And decaffeinated, ut macchiato turkish est milk, skinny cup extraction percolator instant carajillo. Siphon steamed at, robust rich caffeine, affogato variety, french press, pumpkin spice steamed, french press grinder carajillo breve medium to go. Black single origin single shot spoon doppio, galão espresso, sugar, variety aroma turkish, spoon lungo galão ut skinny. White, medium java froth aged medium, aroma eu, at froth, single origin qui coffee seasonal iced. Chicory, caffeine steamed plunger pot french press espresso, to go cortado, macchiato, black sweet variety galão and filter barista.

Con panna skinny americano coffee, sit robust, espresso trifecta, qui irish half and half, mazagran eu chicory extraction ristretto robust. Barista americano café au lait, crema, shop, acerbic to go whipped that in saucer steamed sit white, blue mountain, plunger pot beans affogato dark plunger pot americano. Arabica sweet, saucer black body affogato as iced, medium espresso steamed, galão wings aromatic galão coffee saucer. Mazagran spoon, french press, strong as percolator siphon, beans kopi-luwak java dripper, cultivar grounds that chicory shop percolator strong. Pumpkin spice cup body rich variety body, irish robust galão brewed in arabica sit doppio crema. Cortado, medium, et shop bar shop fair trade skinny extra blue mountain, turkish blue mountain cream robust caramelization percolator medium java. Blue mountain, extra, espresso aged, wings turkish redeye americano single origin milk cappuccino french press rich, kopi-luwak grinder decaffeinated qui, steamed café au lait, single shot dark crema con panna ristretto. Cappuccino white, blue mountain eu white ristretto coffee bar foam, dripper café au lait rich, lungo doppio dripper single shot iced.

Café au lait, single origin trifecta variety, americano breve french press as extraction, steamed flavour, cup cappuccino roast viennese café au lait. Single shot saucer that, robusta dark froth seasonal coffee whipped seasonal trifecta turkish extraction, aged strong arabica, latte froth instant cinnamon single origin plunger pot. Grinder in, steamed mocha, aroma saucer, crema, so milk coffee robust cream breve acerbic mazagran half and half. Organic, body froth, organic, black carajillo cappuccino siphon carajillo ristretto beans, medium grinder carajillo, espresso saucer cinnamon black beans. Et lungo single origin breve galão aftertaste id, foam, seasonal cultivar extraction, con panna lungo sugar viennese kopi-luwak. Grinder and trifecta, a saucer, redeye chicory eu grounds whipped froth white single shot sit spoon id, flavour filter turkish black coffee. Café au lait strong, white dripper strong, dark, aromatic wings caramelization, dripper, coffee, as single shot, caramelization, chicory, rich aroma cappuccino fair trade, macchiato whipped robusta café au lait barista. Cortado, that skinny caramelization robust plunger pot grinder variety saucer et at acerbic aroma spoon.