summary refs log tree commit diff stats
path: root/doc/nimdoc.css
Commit message (Expand)AuthorAgeFilesLines
* follow-up #17837: add `Console` for interactive sessions (#17930)Andrey Makarov2021-05-061-0/+8
* add RST highlighting for command line / shells (also fixes #16858) (#17789)Andrey Makarov2021-04-211-5/+26
* restyle RST option lists (#17637)Andrey Makarov2021-04-101-0/+27
* RST heading improvements (fix #17091) (#17195)Andrey Makarov2021-03-021-0/+1
* RST: implement footnotes and citations (#16960)Andrey Makarov2021-02-151-0/+13
* fix #16885: nimdoc css warning (#16893)zetashift2021-02-011-0/+2
* RST: implement admonitions (#16438)Andrey Makarov2020-12-271-0/+34
* nimdoc: items of ordered lists now have numbers instead of circlesnarimiran2020-11-111-1/+1
* [backport: 1.4] Better linebreaks (#15658)Miran2020-10-221-1/+0
* group procs of the same name in TOC (#15487)Miran2020-10-051-4/+16
* doc/nimdoc.css: align field names to the right (#15217)alaviss2020-08-231-0/+1
* Fix nimdoc invalid css on theme switch class (#14834)Manuel Bojato2020-06-271-4/+5
* Fix #13972 (#14034)Clyybber2020-04-201-2/+2
* feature dracula themed doc (#12816)Andreas Rumpf2019-12-101-214/+800
* [bugfix] rename Nimrod to Nim, fix #11460 (#11462)Miran2019-06-101-1/+1
* Add NEP1 to documentation.Varriount2015-07-101-0/+5
* Fixed missing color definionSimon Krauter2014-10-051-0/+5
* Removes executable bit for text files.Grzegorz Adam Hankiewicz2013-03-161-0/+0
* fixed pango/pangoutils new wrappersAndreas Rumpf2010-02-261-0/+0
* continued work on html/xmlparserrumpf_a@web.de2010-02-141-0/+0
* added tools and web dirsAndreas Rumpf2009-09-151-0/+0
* first releaseRumpf2008-06-231-0/+0
* Initial importAndreas Rumpf2008-06-221-0/+295
' href='#n22'>22 23 24 25 26 27 28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
           
                 

                              
             






















                                                                                                     
                                             














                                                     
                                                                                




                                                                             












                                                                 














                                        

                         
 
discard """
output: "0\n0\n0"
msg: '''
R=3 C=3 TE=9 FF=14 FC=20 T=int
R=3 C=3 T=int
'''
"""

import typetraits

template ok(x) = assert x
template no(x) = assert(not x)

const C = 10

type
  Matrix[Rows, Cols, TotalElements, FromFoo, FromConst: static[int]; T] = concept m, var mvar, type M
    M.M == Rows
    Cols == M.N
    M.T is T

    m[int, int] is T
    mvar[int, int] = T

    FromConst == C * 2

    # more complicated static param inference cases
    m.data is array[TotalElements, T]
    m.foo(array[0..FromFoo, type m[int, 10]])

  MyMatrix[M, K: static[int]; T] = object
    data: array[M*K, T]

# adaptor for the concept's non-matching expectations
template N(M: type MyMatrix): expr = M.K

proc `[]`(m: MyMatrix; r, c: int): m.T =
  m.data[r * m.K + c]

proc `[]=`(m: var MyMatrix; r, c: int, v: m.T) =
  m.data[r * m.K + c] = v

proc foo(x: MyMatrix, arr: array[15, x.T]) = discard

proc genericMatrixProc[R, C, TE, FF, FC, T](m: Matrix[R, C, TE, FF, FC, T]): T =
  static:
    echo "R=", R, " C=", C, " TE=", TE, " FF=", FF, " FC=", FC, " T=", T.name
  
  m[0, 0]

proc implicitMatrixProc(m: Matrix): m.T =
  static:
    echo "R=", m.Rows,
        " C=", m.Cols,
        # XXX: fix these
        #" TE=", m.TotalElements,
        #" FF=", m.FromFoo,
        #" FC=", m.FromConst,
        " T=", m.T.name
    
  m[0, 0]

proc myMatrixProc(x: MyMatrix): MyMatrix.T = genericMatrixProc(x)

var x: MyMatrix[3, 3, int]

static:
  # ok x is Matrix
  ok x is Matrix[3, 3, 9, 14, 20, int]

  no x is Matrix[3, 3, 8, 15, 20, int]
  no x is Matrix[3, 3, 9, 10, 20, int]
  no x is Matrix[3, 3, 9, 15, 21, int]
  no x is Matrix[3, 3, 9, 15, 20, float]
  no x is Matrix[4, 3, 9, 15, 20, int]
  no x is Matrix[3, 4, 9, 15, 20, int]

echo x.myMatrixProc
echo x.genericMatrixProc
echo x.implicitMatrixProc