Hi, here is an example of my code. I can't get the function return value to work properly. I've simplified the function to make it easier to deal with. Any help would be appreciated! :)
import std/tables
import std/strtabs
import std/strutils
import std/enumerate
import std/sequtils
import std/strformat
# {"Azure service" : Resource provider namespace":}
let azProviders = {
 "Azure Active Directory Domain Services": "Microsoft.AAD",
 "core": "Microsoft.Addons"
}.newTable()
const arrSize = 187
proc createFuzzyDataStructs(fuzzyTable: TableRef[string, string]): tuple[array[string], array[string]] =
    
    
    let keyListFuzzy: array[0..arrSize, string]
    let valListFuzzy: array[0..arrSize, string]
    #
    let keyRef: array[0..arrSize, string]
    let valRef: array[0..arrSize, string]
    
    
    var azProvidersReversed = initTable[string, string]()
    
    for idx, key, value in enumerate(fuzzyTable.pairs()):
                    #echo(idx, key, value)
                    
                    ### Create reversed dictionary
                    azProvidersReversed[value] = key
                    
                    # create arrays with lkower case & no spaces
                    keyListFuzzy[idx] = key.toLowerAscii().replace(
                                                    " ", "")
                    valListFuzzy[idx] = value.toLowerAscii(
                                    ).replace(" ", "")
                    
                    # add ref values with exact values
                    keyRef[idx] = key
                    valRef[idx] = value
    
    return (keyListFuzzy, valListFuzzy)
var (keyListFuzzy, valListFuzzy)  = createFuzzyDataStructs(azProviders)
proc createFuzzyDataStructs(fuzzyTable: TableRef[string, string]): (seq[string], seq[string]) =
Please read a tutorial.
Maybe?
proc createFuzzyDataStructs(fuzzyTable: TableRef[string, string]): tuple[array[0..arrSize, string], array[0..arrSize, string]] =
Thanks very much for the answers guys. I'm still a bit confused even having read several sources and I still do not have a working solution.
@Araq your solution involves returning a tuple of seq[string] s, which is not what I am aiming to do. Is it not possible to return a tuple of arrays?
I notice there is an openArray type that can be used in proc arguments, but it does not work for me as a return type within a tuple as I think it only works in arguments. i believe this is so that the proc can take either a seq or an array as an argument.
Apologies if my question is basic, but I am not seeing info on the array return type syntax even in the manual
If someone could point me to an appropriate tutorial on this, I would be very grateful. :)
Best
Arrays are static typed so you need to specify the size of them:
type MyArr = array[arrSize, string]
proc createFuzzyDataStructs(fuzzyTable: TableRef[string, string]): (MyArr, MyArr) = ...
@ElegantBeef
Awesome! that worked! :) Many thanks for your help. the working code if anyone needs an example is thus:
const arrSize = 187
type myArray = array[0..arrSize, string]
proc createFuzzyDataStructs(fuzzyTable: TableRef[string, string]): (Table[
        string, string], myArray, myArray, myArray, myArray) =
    
    var keyListFuzzy: array[0..arrSize, string]
    var valListFuzzy: array[0..arrSize, string]
    #
    var keyRef: array[0..arrSize, string]
    var valRef: array[0..arrSize, string]
    
    
    var azProvidersReversed = initTable[string, string]()
    
    for idx, key, value in enumerate(fuzzyTable.pairs()):
        #echo(idx, key, value)
        
        ### Create reversed dictionary
        azProvidersReversed[value] = key
        
        # create arrays with lkower case & no spaces
        keyListFuzzy[idx] = key.toLowerAscii().replace(
                                        " ", "")
        valListFuzzy[idx] = value.toLowerAscii(
            ).replace(" ", "")
        
        # add ref values with exact values
        keyRef[idx] = key
        valRef[idx] = value
    return (azProvidersReversed, keyListFuzzy, valListFuzzy, keyRef, valRef)
let (azProvidersReversed, keyListFuzzy, valListFuzzy, keyRef,
    valRef) = createFuzzyDataStructs(azProviders)
echo "\n azProvidersReversed: ", azProvidersReversed
echo "\n keyListFuzzy: ", keyListFuzzy
echo "\n valListFuzzy: ", valListFuzzy
echo "\n keyRef: ", keyRef
echo "\n valRef: ", valRef
yes it would be great to be able to write tuple[int, int] and have a tuple with anonymous field names.