Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Stack/Nemerle/stack.nemerle
Normal file
34
Task/Stack/Nemerle/stack.nemerle
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
public class Stack[T]
|
||||
{
|
||||
private stack : list[T];
|
||||
|
||||
public this()
|
||||
{
|
||||
stack = [];
|
||||
}
|
||||
|
||||
public this(init : list[T])
|
||||
{
|
||||
stack = init;
|
||||
}
|
||||
|
||||
public Push(item : T) : Stack[T]
|
||||
{
|
||||
Stack(item::stack)
|
||||
}
|
||||
|
||||
public Pop() : T * Stack[T]
|
||||
{
|
||||
(stack.Head, Stack(stack.Tail))
|
||||
}
|
||||
|
||||
public Peek() : T
|
||||
{
|
||||
stack.Head
|
||||
}
|
||||
|
||||
public IsEmpty() : bool
|
||||
{
|
||||
stack.Length == 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue