Dynamic Hash-like data-structure in Fortran [closed] - data-structures

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Is there a library usable in Fortran, which allows the usage of sparse dynamic arrays (hash/dictionary like) besides the Judy arrays?

I have created an abstracted dictionary in fortran which might suit your needs.
See: https://github.com/zerothi/fdict
Basically it lets you do
type(dict) :: dic, dic2
dic = ('KEY'.kv.1)
dic = dic //('next'.kv. (/3.,5.,6./))
dic = dic //('string'.kv.'Hello world')
dic2 = ('string2'.kv.'Test')
dic = dic // ('dic2'.kvp.dic2)
Where you can save all intrinsic types and it can easily be extended to contain other data-types, it defaults to initially contain itself as another value. (the last line retains a dictionary as a pointer)
It does .kv. == key : value designation which is a deep copy, and
.kvp. == key : pointer which is a reference copy.
In this way you can store huge data without having to duplicate data and retrieve the pointer at some later point.
To elaborate on the idea, all data is stored as address pointers using a transfer call from a derived type containing the data pointer. In this way you trick the compiler to hand you the address of the fortran derived type, but forces you to retrieve it in the exact same manner.
By .kv. a pointer of the data-type is allocated and subsequently pointed to by the data-container, then afterwards the allocated pointer is nullifyied and lost thus forcing the user to know what they are doing (there is no garbage-collector in it ;) ).
By .kvp. the pointer is directly saved without duplicating any memory.
The nice thing is that it is fortran90 compliant.

Haven't seen one built-in, but google returns a few:
FLibs: http://flibs.sourceforge.net/
Hash Tables: http://burtleburtle.net/bob/hash/evahash.html and http://www.cris.com/~Ttwang/tech/inthash.htm.

Related

Is there a way to print a string variable in its 2 words format? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I would like to find a clear way to demonstrate concretely that a variable of type string holds a 2-words data structure (at least as far as I understand it).
This demonstration is for didactic purposes.
So, as I know, a string is a 2 words data structure where one word holds the address of the underlying slice of bytes and the word holds the length.
Given a variable defined like this a := "a string literal", is there a way to view (or print) the content of the variable in its 2 words format so that people can actually see this 2-words structure?
is there a way to view (or print) the content of the variable in its 2 words format?
No, because this is an unspecified implementation detail.
If you are okay with code that might brake: Use reflect.StringHeader. See unsafe.Pointer point (6) on how to do this.
Best not to do this. As said: this is a deliberately hidden implementation detail.

Map of type 'a key -> 'a in Rust [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
In OCaml, there is a construct called univ_map.t, which allows you to map from 'a Type_equal.Id.t values to 'as. Here is an example.
Is there a construct that would allow me to do something similar in Rust? I know in OCaml they are implemented with open variants, which I don't believe Rust has.
I'm not familiar with OCaml, but looking at the docs:
Univ_map: Universal/heterogeneous maps [...] useful for storing values of arbitrary type in a single map [...] built on top of Univ.
Univ: An extensible universal variant type. Every type id corresponds to one branch of the variant type.
The closest thing that Rust has that sounds like Univ is the Any trait, which is designed to represent any type (with exceptions). However, there is no standard type for storing a collection of Anys that is accessed by its TypeId. From looking how popular crates handle this, its usually a bespoke wrapper around HashMap<TypeId, Box<dyn Any>> or similar. I hope I've understood correctly.

Is there any language that allows spaces in its variable names [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Is there (or was there ever) any non-trivial language that allows spaces in its variable names?
I am aware of the language Whitespace, but I'm interested in a language that was actually used for something besides demonstration.
I ask this out of pure curiosity.
In a way, yes. Several languages's variable names are really just keys to a higher-level object. Both Coldfusion and Javascript come to mind. In Javascript, you can write foo=bar, but what you've really said is:
window['foo'] = bar;
You could just as easily write
window['i haz a name'] = bar;
The various scopes in Coldfusion can also be treated as either a (dict|hash|associative array) or a name.
Of course, once you've created a name with whitespace, it's harder to access without using the hash lookup syntax.
TSQL will allow you to use whitespace in table and column names aslong as you have it between square braces [ ]
Theres a fantastic article on just what sql will let you get away with here http://www.sqlservercentral.com/blogs/philfactor/archive/2009/08/14/evil-code.aspx

Dictionary API or Library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Does anyone know of a good dictionary API or ruby library to lookup the definitions of words?
I'm thinking it should work something like:
I call get_definition(word)
It returns the definition for that word (ideally in some way to easily format the definition for display.
Thanks
Wordnik.com has several word-info APIs, including a definitions API. More info is here: http://developer.wordnik.com/
[I work for Wordnik. We will have more APIs soon, let us know what you want!]
I discovered a webservice for this yesterday.
Go to the British Council homepage and double click on any word (that isn't already a hyperlink).
This should open a popup window with a Cambridge Dictionary definition in it. The API is relatively simple (and it is a public API, I checked it yesterday):
http://dictionary.cambridge.org/learnenglish/results.asp?searchword=SEARCH_PHRASE&dict=L
For reference, here's the code they use to launch this on double-click:
/* BC double-click pop-up dictionary */
var NS = (navigator.appName == "Netscape" || navigator.product == 'Gecko') ? 1 : 0;
if (NS) document.captureEvents(Event.DBLCLICK);
document.ondblclick = dict;
var dictvar;
function dict() {
if (NS) {
t = document.getSelection();
pass_to_dictionary(t);
} else {
t = document.selection.createRange();
if(document.selection.type == 'Text' && t.text != '') {
document.selection.empty();
pass_to_dictionary(t.text);
}
}
}
function pass_to_dictionary(text) {
//alert(text);
if (text > '') {
window.open('http://dictionary.cambridge.org/learnenglish/results.asp?searchword='+text+ '&dict=L', 'dict_win', 'width=650,height=400,resizable=yes,scrollbars=yes');
}
}
Ruby-WordNet sounds like it does what you're looking for:
Ruby-WordNet is a Ruby interface to
the WordNet® Lexical Database. WordNet
is an online lexical reference system
whose design is inspired by current
psycholinguistic theories of human
lexical memory. English nouns, verbs,
adjectives and adverbs are organized
into synonym sets, each representing
one underlying lexical concept.
Different relations link the synonym
sets.
there's also wrappers for dictionary.com's API (a few years old)
http://rubyforge.org/snippet/detail.php?type=snippet&id=53
http://rubyforge.org/snippet/detail.php?type=snippet&id=52
and wiktionary
http://eightpence.com/ninjawords-a-fast-online-dictionary-fast-like-a-ninja/

SNMP MIB Visualizer recommendations? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Are there any free visualization tools for MIBs? I've been assigned some SNMP trap normalization/enrichment work and been given Cisco ONS 15454s to start with. The MIBs seem more complex than others I have seen. Lots of object cross-references, including some to objects that are defined in other MIBs and exported. A quick example of trying to trace down the port number of an alarm:
Alarm definition:
Cerent454AlarmEntry ::= SEQUENCE {
cerent454AlarmIndex INTEGER,
cerent454AlarmObjectType Cerent454EntityClass,
cerent454AlarmSlotNumber INTEGER,
cerent454AlarmPortNumber CerentPortNumber,
cerent454AlarmLineNumber INTEGER,
cerent454AlarmObjectIndex INTEGER,
cerent454AlarmType Cerent454AlarmType,
cerent454AlarmState CerentNotificationClass,
cerent454AlarmTimeStamp TimeStamp,
cerent454AlarmObjectName DisplayString,
cerent454AlarmAdditionalInfo DisplayString
}
CerentPortNumber references from the same file (CERENT-454.mib):
IMPORTS
(...)
CerentPortNumber
FROM CERENT-TC
(...)
cerent454AlarmPortNumber OBJECT-TYPE
SYNTAX CerentPortNumber
ACCESS read-only
STATUS mandatory
DESCRIPTION
"This will indicate what is the port
of the object which raised this alarm."
::= { cerent454AlarmEntry 40 }
The actual syntax for CerentPortNumber, from CERENT-TC.mib:
CerentPortNumber ::=
INTEGER
{ unknown (1),
port0 (5),
port1 (10),
port2 (20),
(...)
port62 (620),
port63 (630),
port64 (640),
portAll (10240)
}
Maybe this isn't as complex as it feels, but this is just one small example. It feels like there should be a GUI-based "explorer" type app that would allow me to see these references easily without a lot of back and forth between files and locations in files. Any recommendations?
I use iReasoning's MIB Browser.
The one I used to use was MIB Browser.
But looking for MIB viewer on google gives you lots of other solutions.
I expect you can use Mgsoft-MIB Browser trail version for some extent.
Regards
Haranadh
You can use tkmib and snmpb in Linux-land.

Resources