/**
 * Converts the given data structure to the specified type.
 *
 * @param data The data structure to be converted.
 * @param conversionType The type to convert the data structure to. Options are: 'list', 'dictionary', 'set', or 'tuple'.
 * @return The converted data structure based on the specified type.
 */
fun convertDataStructure(data: Any, conversionType: String): Any {

    return when (conversionType) {
        "list" -> {
            when (data) {
                is List<*> -> data
                is Map<*, *> -> data.values.toList()
                is Set<*> -> data.toList()
                is Array<*> -> data.toList()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to list")
            }
        }
        "dictionary" -> {
            when (data) {
                is List<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                is Map<*, *> -> data
                is Set<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                is Array<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to dictionary")
            }
        }
        "set" -> {
            when (data) {
                is List<*> -> data.toSet()
                is Map<*, *> -> data.values.toSet()
                is Set<*> -> data
                is Array<*> -> data.toSet()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to set")
            }
        }
        else -> throw IllegalArgumentException("Unsupported conversion type")
    }
}
/**
 * Converts the given data structure to the specified type.
 *
 * @param data The data structure to be converted.
 * @param conversionType The type to convert the data structure to. Options are: 'list', 'dictionary', 'set', or 'tuple'.
 * @return The converted data structure based on the specified type.
 */
fun convertDataStructure(data: Any, conversionType: String): Any {
/**
 * Converts the given data structure to the specified type.
 *
 * @param data The data structure to be converted.
 * @param conversionType The type to convert the data structure to. Options are: 'list', 'dictionary', 'set', or 'tuple'.
 * @return The converted data structure based on the specified type.
 */
fun convertDataStructure(data: Any, conversionType: String): Any {

    return when (conversionType) {
        "list" -> {
            when (data) {
                is List<*> -> data
                is Map<*, *> -> data.values.toList()
                is Set<*> -> data.toList()
                is Array<*> -> data.toList()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to list")
            }
        }
        "dictionary" -> {
            when (data) {
                is List<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                is Map<*, *> -> data
                is Set<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                is Array<*> -> data.mapIndexed { index, item -> index.toString() to item }.toMap()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to dictionary")
            }
        }
        "set" -> {
            when (data) {
                is List<*> -> data.toSet()
                is Map<*, *> -> data.values.toSet()
                is Set<*> -> data
                is Array<*> -> data.toSet()
                else -> throw IllegalArgumentException("Unsupported data type for conversion to set")
            }
        }
        else -> throw IllegalArgumentException("Unsupported conversion type")
    }
}