本文介绍了Opa:howo来操纵stringmap(和其他地图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Stringmap,在里面添加一些值,并传递一些函数。我已经尝试过:

  import stdlib.core.map 

mymap = StringMap_empty



mymap [rabbit] = 12


函数addmap(map)
{
map [兔子] = 24
}

但没有编译。我只能使用stringmap通过数据库! ( - >数据库stringmap(int)/ myMap)



我的代码有什么问题?

解决方案

Opa是一种功能性编程语言。您应该阅读此主题了解更多信息:

  mymap = StringMap。空

mymap = StringMap.add(rabbit,12,mymap)
//你不能只写StringMap.add(rabbit,12,mymap)
//因为默认值是不可变
//函数返回添加新元素的地图


函数addmap(map)
{
StringMap.add(rabbit,24,map)
}

mymap = addmap(mymap)


I want to create a Stringmap, add some values inside, and pass it some function. I've tried this :

import stdlib.core.map

mymap = StringMap_empty



mymap["rabbit"] = 12


function addmap(map)
{
        map["rabbit"] = 24
}

But nothing compile. I can only use stringmap througt database ! (-> database stringmap(int) /myMap )

What's wrong with my code ?

解决方案

Opa is a functional programming language. You should read this thread for more information:Opa: Iterating through stringmap and forming a new string based on it

mymap = StringMap.empty

mymap = StringMap.add("rabbit", 12, mymap)
// you can't just write StringMap.add("rabbit", 12, mymap)
// because values are by default not mutable
// the function returns the map with the new element added


function addmap(map)
{
        StringMap.add("rabbit", 24, map)
}

mymap = addmap(mymap)

这篇关于Opa:howo来操纵stringmap(和其他地图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 01:50