Skip to content

Commit

Permalink
moving specfun and image into extra/
Browse files Browse the repository at this point in the history
updating list example
removing some examples that were basically copy&paste of other code
  • Loading branch information
JeffBezanson committed Mar 17, 2012
1 parent 55dce00 commit c2104c9
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 632 deletions.
321 changes: 0 additions & 321 deletions examples/dsparsemat.jl

This file was deleted.

19 changes: 16 additions & 3 deletions examples/list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Cons{T} <: List{T}
end

cons{T}(h::List{T}, t::List{List{T}}) = Cons{List{T}}(h, t)
cons(x,y) = Cons(x,y)
cons{T}(h, t::List{T}) = Cons{T}(h, t)

nil(T) = Nil{T}()
nil() = nil(Any)
Expand Down Expand Up @@ -43,7 +43,20 @@ end

list() = nil()
list{T}(first::T) = cons(first, nil(T))
list(first, rest...) = cons(first, list(rest...))
function list(elts...)
l = nil()
for i=length(elts):-1:1
l = cons(elts[i],l)
end
return l
end
function list{T}(elts::T...)
l = nil(T)
for i=length(elts):-1:1
l = cons(elts[i],l)
end
return l
end

length(l::Nil) = 0
length(l::Cons) = 1 + length(tail(l))
Expand All @@ -64,7 +77,7 @@ end

append(lst::List) = lst

function append{T}(lst::List{T}, lsts...)
function append(lst::List, lsts...)
n = length(lsts)
l = lsts[n]
for i = (n-1):-1:1
Expand Down
Loading

0 comments on commit c2104c9

Please sign in to comment.