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
CellToolbar | |
In [3]: | |
abstract type Stone end | |
| |
struct Empty <: Stone end | |
struct Black <: Stone end | |
struct White <: Stone end | |
| |
Base.show(io::IO, ::Black) = print(io, "⚈") |
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
abstract type Stone end | |
struct Empty <: Stone end | |
struct Black <: Stone end | |
struct White <: Stone end | |
Base.show(io::IO, ::Black) = print(io, "⚈") | |
Base.show(io::IO, ::White) = print(io, "⚆") | |
Base.show(io::IO, ::Empty) = print(io, "·") |
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
julia> abstract type Stone end | |
julia> struct Empty <: Stone end | |
julia> struct Black <: Stone end | |
julia> struct White <: Stone end | |
julia> Base.show(io::IO, ::Black) = print(io, "⚈") | |
julia> Base.show(io::IO, ::White) = print(io, "⚆") | |
julia> Base.show(io::IO, ::Empty) = print(io, "·") |
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
/* | |
* board.js - Game logic for the board game Go | |
*/ | |
var Board = function(size) { | |
this.current_color = Board.BLACK; | |
this.size = size; | |
this.board = this.create_board(size); | |
this.last_move_passed = false; | |
this.in_atari = false; | |
this.attempted_suicide = false; |
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
Last login: Fri Jan 12 13:47:11 on ttys000 | |
Kevins-MBP:~ Corvus$ exec '/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia' | |
_ | |
_ _ _(_)_ | A fresh approach to technical computing | |
(_) | (_) (_) | Documentation: https://docs.julialang.org | |
_ _ _| |_ __ _ | Type "?help" for help. | |
| | | | | | |/ _` | | | |
| | |_| | | | (_| | | Version 0.6.0 (2017-06-19 13:05 UTC) | |
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release | |
|__/ | x86_64-apple-darwin13.4.0 |
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
julia> abstract type Stone end | |
julia> struct Black <: Stone end | |
julia> struct White <: Stone end | |
julia> abstract type Emptiness end | |
julia> struct Empty <: Emptiness end | |
# julia> Base.show(io::IO, ::Empty) = print(io, "·") | |
# julia> Base.show(io::IO, ::Black) = print(io, "⚈") | |
# julia> Base.show(io::IO, ::White) = print(io, "⚆") |
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
julia> i = 1; | |
julia> runningtime1 = 100i^2; | |
julia> runningtime2 = 2^i; | |
julia> while true # is a loop that never terminates, unless there's a break | |
println(i) | |
if runningtime1 < runningtime2 # if condition is true, break | |
break |
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
# for n = 1, `log(2, 1) = 0`, making merge time equal 0 | |
# start with n = 2 | |
julia> n = 2; | |
julia> insertiontime = 8*n^2; | |
julia> mergetime = 64*n*log(2,n); | |
julia> while true |
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
julia> abstract type Stone end | |
julia> struct Black <: Stone end | |
julia> struct White <: Stone end | |
julia> abstract type Emptiness end | |
julia> struct Empty <: Emptiness end | |
julia> Base.show(io::IO, ::Empty) = print(io, "·") | |
julia> Base.show(io::IO, ::Black) = print(io, "⚈") | |
julia> Base.show(io::IO, ::White) = print(io, "⚆") |
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
julia> function recursive_factorial(n) | |
# first case (base) | |
if n == 0 | |
return 1 | |
end | |
# second case (recursive) | |
if n >= 1 | |
return n*factorial(big(n - 1)) | |
end | |
end |
OlderNewer