FSharp - OCaml based .NET functional first multi-paradigm language
It's open sourced and doesn't need Visual Studio, but, even that should be free.
Language site. Great starting point to beginning information.
| defmodule SomeTest do | |
| use ExUnit.Case | |
| def some_function(%{arg1: "thing", arg3: _}) do | |
| :two | |
| end | |
| def some_function(%{arg1: "thing", arg2: _}) do | |
| :one | |
| end | |
| def some_function(_) do |
FSharp - OCaml based .NET functional first multi-paradigm language
It's open sourced and doesn't need Visual Studio, but, even that should be free.
Language site. Great starting point to beginning information.
| <html> | |
| <head> | |
| <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
| <script type="application/javascript"> | |
| $(document).ready(function(e){ | |
| $("button.delete").click(function(){ | |
| var org_name = $(this).parents("tr") | |
| .children("td:first-child").html(); | |
| alert(org_name); | |
| }); |
| (defn zero-pad [n number-string] | |
| (->> | |
| (concat (reverse number-string) (repeat \0)) | |
| (take n) | |
| reverse | |
| (apply str))) | |
| (defn prefix [file-name] | |
| (str "ns" (clojure.string/replace file-name #"^\d+" #(pad 3 %)))) |
| namespace MyApplication { | |
| public partial class MainWindow | |
| { | |
| private readonly ViewModel _vm; | |
| private bool _close; | |
| public MainWindow() | |
| { | |
| InitializeComponent(); |
| type Frame = StandardFrame of int * int | |
| | SpareFrame of int * int | |
| | StrikeFrame | |
| type Game = Frame list | |
| let score game = | |
| let nextRoll frames = | |
| match frames with | |
| | [] -> 0 | |
| | StandardFrame(a,_)::_ -> a |
| type Fizzable = Plain of int | |
| | Fizzy | |
| | Buzzy | |
| | FizzyBuzzy | |
| let toFizzable n :Fizzable = | |
| match n with | |
| | _ when (n % 3) = 0 && n % 5 = 0 -> FizzyBuzzy | |
| | _ when n % 3 = 0 -> Fizzy | |
| | _ when 0 = n % 5 -> Buzzy |
| // Adapted from http://igstan.ro/posts/2011-05-02-understanding-monads-with-javascript.html | |
| type StackResult = {value: int; stack: int list} | |
| let push element stack = | |
| {value= element; stack = element :: stack} | |
| let pop stack = | |
| {value= (List.head stack); stack = (List.tail stack)} | |
| let bind operation continuation stack = | |
| let r = operation stack |
| def using(object, message, *args) | |
| begin | |
| yield if block_given? | |
| ensure | |
| object.send(message, *args) | |
| end | |
| obj = SomthingToClose.connect |
| -- Socket based network library | |
| -- http://www.haskell.org/ghc/docs/6.10.4/html/libraries/network/Network-Socket.html | |
| import Network.Socket | |
| -- System io calls. Posix based | |
| -- http://lambda.haskell.org/hp-tmp/docs/2011.2.0.0/ghc-doc/libraries/haskell2010-1.0.0.0/System-IO.html | |
| import System.IO |