Impact factor for posts is a measurement of importance.

Impact factor for users reflect their authority, reputation and contribution on a particular topic.

Rating reflects the quality of posts.

Rating on Voofie is not a simple average of all ratings, but a weighted average of rating, weighted by the impact factor of users who rated.

Explore exciting communities of

Documentation of dict: A Mathematica Dictionary(Associative Array) using MathOO

08 Nov 10

This document is a documentation of the dict class in MathOO-packages. Basically it behaviors very similarly to Python dict.

Bookmark and Share

Content

Documentation of dict class

After you load the package, by running:

Get["basic.m"]

you can start to use it.

Generating a new dictionary: new[dict][items___];

namePhone = new[dict][];

generates an empty dictionary.

To add terms when creating the object, do:

namePhone = new[dict][{"john","132452"},{"peter","224235"},{"mary","213414"}];

Items look up: get[key], get[key, default]

In: namePhone.get["john"]
Out: 132452

If the key does not exist, Null will be returned.

In: namePhone.get["john1"] === Null
Out: True

To get a default value instead of Null, supply a second argument.

In: namePhone.get["john1", "Not Found"]
Out: Not Found

Adding new entry/entries: put[key, values], addList[items__]

To add a new entry, do:

namePhone.put["june", "241231"]

To add more than one entry at a time, do:

namePhone.addList[{"tom", "241231"}, {"kings", "241255"}]

Getting all the keys: keys[]

In: namePhone.keys[]
Out: {john, peter, mary, tom, kings, june}

Getting all values: values[]

In: namePhone.values[]
Out: {132452,224235,213414,241231,241255,241231}

Getting all items: items[]

In: namePhone.items[]
Out: {{john,132452},{peter,224235},{mary,213414},{tom,241231},{kings,241255},{june,241231}}

Check if a key exists: hasKey[key]

In: namePhone.hasKey["john"]
Out: True

Getting the number of records: length[]

In: namePhone.length[]
Out: 6

Deleting a single record: delete[key]

namePhone.delete["june"]

Deleting all records: clear[]

namePhone.clear[]

Adding all records from one dictionary to another: update[dict1]

In: namePhoneNew = new[dict][{"stephen","124123"},{"judy","2323421"}];
In: namePhone.update[namePhoneNew];
In: namePhone.items[]
Out: {{john,132452},{peter,224235},{mary,213414},{june,241231},{tom,241231},{kings,241255},{stephen,124123},{judy,2323421}}
0 Comments

Please login to post comment.

What is Voofie?

Voofie organizes knowledge, discovers useful resources and recognizes knowledgable users.

Bookmark your blog in Voofie to get more traffic as well as building a reputation in your field!

Explore more about it. Become a member—our FREE Registration takes just seconds.

Page Info
12Impacts
0/0 rates
1134
Your Rating:
Version: 2
Last update: 08 Nov 10
History Permalink
Author
Avatar for ross_tang

Ross Tang (ross_tang)

Degree in Physics and Mathematics, Master in Physics
香港

  • Mathematica
  • 72
  • Software package (programming)
  • 0
  • MathOO
  • 0