Login
|
Signup
langref.org
-
ruby
,
cpp
,
clojure
,
fsharp
...
add..
all
csharp
fantom
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Lists
Declaration
Define an empty list
Assign the variable
"list"
to a list with no elements
ruby
list = []
list = []
ruby
list = Array.new
list = Array.new
cpp
C++/CLI .NET 2.0
Generic::List<String^>^ list = gcnew Generic::List<String^>();
using namespace System;
using namespace System::Collections;
int main()
{
Generic::List<String^>^ list = gcnew Generic::List<String^>();
}
cpp
std::list<std::string> list;
#include <string>
#include <list>
int main()
{
std::list<std::string> list;
}
clojure
(list)
(list)
clojure
'()
'()
fsharp
let list = []
#light
open System
let list = []
fsharp
let list = List.empty
#light
open System
// True 'list' created - equivalent to []
let list = List.empty
fsharp
let list = new Generic.List<string>()
#light
open System
open System.Collections
// .NET 'Generic.List' is actually an array type, and is aliased in f# as 'ResizeArray<T>'
let list = new Generic.List<string>()
fsharp
let list = new Generic.LinkedList<string>()
#light
open System
open System.Collections
// .NET 'Generic.LinkedList' is a node-based, list-like structure, though not a true f# 'list'
let list = new Generic.LinkedList<string>()
erlang
List = [],
-module(emptylist).
-export([start/0]).
start() ->
List = [],
io:format("~B~n", [length(List)]).
Submit a new solution for
ruby
,
cpp
,
clojure
,
fsharp
...
There are 15 other solutions in
additional
languages (
csharp
,
fantom
,
go
,
groovy
...)