Login
|
Signup
langref.org
-
ruby
,
cpp
,
fsharp
,
groovy
...
add..
all
clojure
csharp
erlang
fantom
go
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
Maps
Declaration
Define an unmodifiable empty map
ruby
map = {}.freeze
map = {}.freeze
cpp
const std::map<T1,T2> immutable_map_instance_of_type_t1_to_t2;
const std::map<T1,T2> immutable_map_instance_of_type_t1_to_t2;
fsharp
// Most native fsharp data structures are immutable - updating a 'map' sees a modified copy created
let map = Map.empty
#light
open System
open System.Collections
// Most native fsharp data structures are immutable - updating a 'map' sees a modified copy created
let map = Map.empty
groovy
empty = Collections.EMPTY_MAP
empty = Collections.EMPTY_MAP
groovy
map = [:].asImmutable()
map = [:].asImmutable()
groovy
with commons collections
def empty = MapUtils.EMPTY_SORTED_MAP
import org.apache.commons.collections.MapUtils
def empty = MapUtils.EMPTY_SORTED_MAP
groovy
with google collections
def empty = ImmutableMap.of()
import com.google.common.collect.ImmutableMap
def empty = ImmutableMap.of()
haskell
import qualified Data.Map as Map
output :: Map.Map k v
output = Map.empty
import qualified Data.Map as Map
output :: Map.Map k v
output = Map.empty
Submit a new solution for
ruby
,
cpp
,
fsharp
,
groovy
...
There are 13 other solutions in
additional
languages (
clojure
,
erlang
,
fantom
,
java
...)