The following is a list of programming languages and their syntax for doing metaprogramming.
Macros in C are just glorified string substitution.
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn) | |
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2) | |
import Signal exposing (Signal, Mailbox, mailbox, send) | |
import List | |
--------------------------------- | |
-- THIRD PARTY LIBRARY IMPORTS -- |
(->>) : a -> List (a -> a) -> a | |
(->>) x list = case list of | |
[] -> x | |
f :: fs -> (->>) (f x) fs |
import String exposing (toList) | |
import Maybe | |
import List exposing (member) | |
import Graphics.Element exposing (show) | |
toChar x = | |
if | x == 0 -> '0' | |
| x == 1 -> '1' | |
| x == 2 -> '2' | |
| x == 3 -> '3' |
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Json.Decode as Decode exposing (Decoder, object2, map, string, list, (:=)) | |
import Task exposing (Task, andThen, succeed, fail, onError) | |
import Signal exposing (Signal, Mailbox, mailbox, message, send) | |
import String | |
------------------------- |
matchOn : String -> String -> Maybe String | |
matchOn start string = | |
if startsWith start string | |
then | |
Just <| dropLeft (length start) string | |
else | |
Nothing |
shrinkInt : Int -> List Int | |
shrinkInt n = | |
if n < 0 | |
then | |
-n :: List.map ((*) -1) (series 0 -n) | |
else | |
series 0 n | |
series : Int -> Int -> List Int |
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
*/ | |
'use strict'; | |
var React = require("react-native"); | |
var { | |
AppRegistry, |
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Task exposing (Task, succeed, andThen, onError) | |
import Json.Decode exposing (Decoder, object2, (:=), string, int, list, map) | |
import Signal exposing (Signal, Mailbox, mailbox, send) | |
import List | |
--------------------------------- | |
-- THIRD PARTY LIBRARY IMPORTS -- |