This file contains hidden or 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
| function getInfoLog(obj::GLuint) | |
| # Return the info log for obj, whether it be a shader or a program. | |
| isShader = glIsShader(obj) | |
| getiv = isShader == GL_TRUE ? glGetShaderiv : glGetProgramiv | |
| getInfo = isShader == GL_TRUE ? glGetShaderInfoLog : glGetProgramInfoLog | |
| # Get the maximum possible length for the descriptive error message | |
| int::Array{GLint, 1} = [0] | |
| getiv(obj, GL_INFO_LOG_LENGTH, int) | |
| maxlength = int[1] |
This file contains hidden or 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
| code: | |
| function Base.getindex{K}(t::TreapNode{K}, index::Int) | |
| 1 <= index <= t.size || throw(KeyError(key)) | |
| while t.left.size != index - 1 | |
| if index <= t.left.size | |
| t = t.left | |
| else | |
| index = index - t.left.size - 1 | |
| t = t.right |
This file contains hidden or 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 Base: isempty, start, next, done, length, getindex, minimum, maximum, search, show | |
| export Treap, TreapNode | |
| type TreapNode{K} | |
| priority::Float64 | |
| size::Int | |
| key::K | |
| left::TreapNode{K} | |
| right::TreapNode{K} |
This file contains hidden or 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
| NB. http://link.springer.com/article/10.1007%2FBF01908446#page-2 | |
| iter =: monad : '(2 * 0 1 { $ +/~y) $, +/~y' | |
| m =: 2 3 $ 0 _4 1 1 _3 2 | |
| NB. random matrix with entries from _10 to 10: | |
| NB. m =: 2 3 $ (? 6 $ 20) - 10 | |
| viewmat iter^:4 m |
This file contains hidden or 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
| xs =: (i: 10) % 10 | |
| ys =: (i: 20) % 10 | |
| grid =: ys j./ xs | |
| in =: 4 > | | |
| out =: 1 - in | |
| trim =: (* in) + (_ * out) | |
| iter =: trim @ (+ *:) | |
| require 'viewmat' |
NewerOlder