百度首页 | 百度空间
 
查看文章
 
dictionary (key/value pair)
2008-05-12 00:04
今天想在bash script上弄个dictionary玩一下,找了很多资料。。都没找到,
只好让ic总问问他那个bash script耍得很nb的朋友,在bash script 中到底
有没dictionary. 结果晚饭回来后,他说问了,没有。lol 。。太可惜了。。。
所以写了以下几种语言的dictionary.....
c的,我不会写。。以前看过sam帅哥写的sql banner扫描器的代码,发现他是
建了2个大小一样的数组,其中一个放banner 。然后扫描器对sql server端口
发包。得到respon 后,和一个数组的数据匹配,找到这个数据在数组的位置,
再打印出存banner的这个数组中相同位置的值。这好像不是mapping吧。。。


Smalltalk:

d := Dictionary with: 'dog' -> 'chien' with: 'cat' -> 'chat' with: 'cow' -> 'vache'.
d at: 'horse' put: 'cheval'.
Transcript show: (d at: 'horse'); cr


Python:

d = {'dog': 'chien', 'cat': 'chat', 'cow': 'vache'}
d['horse'] = 'cheval'
print d['horse']

TCL:

set d [dict create dog chien cat chat cow vache]
dict set d horse cheval
puts [dict get $d horse]



Java:

HashMap<String,String> d = new HashMap<String,String>();
d.put("dog", "chien");
d.put("cat", "chat");
d.put("cow", "vache");
d.put("horse", "cheval");
System.out.println(d.get("horse");






类别:奇技淫巧 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu