Hashes - HiStructClient/femcad-doc GitHub Wiki

The values returned by a hash function are called hashes. A hash function is any function that can be used to map data of arbitrary size to data of fixed size.

In FemCad script we use the following function to convert string to hash

Fcs.Converters.StringToMd5Hash( string )

Hash can be afterwards managed as a standard string (using substring, listed in a table etc.)

Example of usage
    There was in intention to get rid of identical items in a dynamic object so that only unique items are left untouched.
The following array was operated:
inputArray := [
   {floorLength = 7, columnDists = [3, 3]},
   {floorLength = 7, columnDists = [3, 3,1]},
   {floorLength = 8, columnDists = [3, 2, 4]},
   {floorLength = 8, columnDists = [3, 2, 4]},
   {floorLength = 7, columnDists = [3, 3]},
   {floorLength = 7, columnDists = [3, 3]},
   {floorLength = 8, columnDists = [3, 2, 4]},
]
    Solution, utilizing convertion to hash looks as below:
range           := Fcs.Converters.EnumerableRange( inputArray.Count )
hashes          := inputArray.Select( i => Fcs.Converters.StringToMd5Hash( ( i ).ToString() ).Substring( 0, 8 ) )
isUniqueOrFirst := range.Select( i => hashes.Take( i + 1 ).Where( hash => hash == hashes[ i ] ).Count == 1 )
outputArray     := range.Where( i => isUniqueOrFirst[ i ] ).Select( i => inputArray[ i ] )

(acknowledgement to Kuboja who is the author of the solution)

⚠️ **GitHub.com Fallback** ⚠️