Last active
March 2, 2016 21:16
-
-
Save nmorse/2147d7488b90b262fd1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Element exposing (show) | |
graph = {nodes=[{id=1, name="test1"}, {id=2, name="test2"}], | |
edges=[{from=2, to=1, e_type="get"}, {from=2, to=1, e_type="set"}, {from=1, to=2, e_type="get"}]} | |
main = | |
show (edgesTo graph.edges 1, edgesToOf graph.edges 1 "get") | |
edgesTo : List { a | to : Int } -> Int -> Int | |
edgesTo list nodeId = | |
case list of | |
[] -> | |
0 | |
first :: rest -> | |
if first.to == nodeId then | |
1 + edgesTo rest nodeId | |
else | |
edgesTo rest nodeId | |
edgesToOf : List { a | to : Int, e_type : String } -> Int -> String -> Int | |
edgesToOf list nodeId edgeType = | |
case list of | |
[] -> | |
0 | |
first :: rest -> | |
if first.to == nodeId && first.e_type == edgeType then | |
1 + edgesToOf rest nodeId edgeType | |
else | |
edgesToOf rest nodeId edgeType | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment