Skip to content

Instantly share code, notes, and snippets.

View kozross's full-sized avatar

Koz Ross kozross

View GitHub Profile
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Type{Int64}
This may have arisen from a call to the constructor Type{Int64}(...),since type constructors fall back to convert methods.
in copy!(::Array{Type{Int64},1}, ::TruthTable.TableIndex) at ./abstractarray.jl:479
in collect(::TruthTable.TableIndex) at ./array.jl:273
in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
in macro expansion at ./REPL.jl:95 [inlined]
in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
# I have the following sauce code:
import Iterators
type MinimaxNode
id :: Int
min_node :: Bool
val :: Nullable{Int}
children :: Vector{MinimaxNode}
end
# I have the following bit of code
using Format
type MinimaxNode
id :: Int
min_node :: Bool
val :: Int
children :: Vector{MinimaxNode}
end
function f(old, # what type is this?
#= I have the following sauce code: =#
module TruthTable
import Base.size, Base.getindex, Base.linearindexing
export Table, random
immutable Table
p :: Int
unpack :: BitVector
end
const lookup_table = sparse(vcat(collect.(repeated.(1:9, binomial.(8, 0:8)))...),
vcat(map(x -> collect(1:x), binomial.(8, 0:8))...),
vcat(collect.(Permutations.(0:8))...)) #Permutations is a custom iterator I define earlier
# I have the following Gawk invocation, which correctly only prints certain fields of a file in a comma-separated list
#
# gawk -F ',' -v NLINES=$(wc -l < members.csv) 'NR > 1 { printf("%s", $4) } NR != nlines && NR > 1 { printf(",") }' members.csv
#
# I'm trying to translate this into an actual script, and I have the following:
#!/usr/bin/gawk -f
FS = ","
NLINES = system("wc -l <" ARGV[1])
! You can't use `\prevdepth' in horizontal mode.
\nointerlineskip ->\prevdepth
-\@m \p@
l.286 \end{slide}
-- I'm trying to write up a schema for an SQLite database storing some data sets
-- Requirements are as follows:
-- 1) Every data set has a unique name
-- 2) Every data set has multiple attributes associated with it
-- 3) Every attribute has several possible values
-- 4) Attributes may be class attributes or non-class attributes
-- 5) Every record is associated with one data set
-- 6) Every record must have exactly one value for every attribute associated with its data set
--
-- Now, I can get as far as point 4 with the following:
@kozross
kozross / .nvimrc
Created December 13, 2017 04:54
Haskell setup
augroup ghciMaps
au!
au FileType haskell nnoremap <silent> <leader>gs :GhciStart<CR>
au FileType haskell nnoremap <silent> <leader>gk :GhciKill<CR>
au FileType haskell nnoremap <silent> <leader>gr :GhciRestart<CR>
au FileType haskell nnoremap <silent> <leader>go :GhciOpen<CR>
au BufWritePost *.hs GhciReload
au BufWritePost *.hs GhciReload
let g:ghci_command = 'stack repl'
let g:ghci_command_line_options = '--ghci-options="-fobject-code -Wall"'
arr = [5, 8, 11, 0]
function bitat(x,i)
x & (1 << (i - 1)) != 0
end
y = BitMatrix(bitat(arr[i], j) for i in 1:4, j in 1:4)
#=
This fails, claiming:
MethodError: Cannot `convert` an object of type Base.Generator{Base.Iterators.Prod2{UnitRange{Int64},UnitRange{Int64}},##9#10} to an object of type BitArray{2}