/tests/overflw/

href='/'>index : Nim
This repository contains the Nim compiler, Nim's stdlib, tools, and documentation. (mirror)ahoang <ahoang@tilde.institute>
summary refs log blame commit diff stats
path: root/tests/concepts/tgraph.nim
blob: a0177a0430da57e4d8db262235196ea31c38f637 (plain) (tree)




























                                                               
discard """
  output: '''XY is Node
MyGraph is Graph'''
"""
# bug #3452
import math

type
    Node* = concept n
        `==`(n, n) is bool

    Graph* = concept g
        var x: Node
        distance(g, x, x) is float

    XY* = tuple[x, y: int]

    MyGraph* = object
        points: seq[XY]

if XY is Node:
    echo "XY is Node"

proc distance*( g: MyGraph, a, b: XY): float =
    sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) )

if MyGraph is Graph:
    echo "MyGraph is Graph"