U UniCore Community Public content rendered for search, speed, and sharing

Documentation

Getting Started

Quick examples to get productive with UniCoreFW.

Learn how to use UniCoreFW by following these quick examples.

Creating an Instance

from unicorefw import UniCoreFW, UniCoreFWWrapper

# Create an instance with a list
uc_list = UniCoreFWWrapper([1, 2, 3, 4, 5])

# Create an instance with a dictionary
uc_dict = UniCoreFWWrapper({'name': 'John', 'age': 30, 'city': 'New York'})

# Create an instance with a set
uc_set = UniCoreFWWrapper({1, 2, 3, 4, 5})

Working with Arrays

# Map - transform each element
doubled = uc_list.map(lambda x: x * 2)  # [2, 4, 6, 8, 10]

# Filter - keep elements that match a condition
evens = uc_list.filter(lambda x: x % 2 == 0)  # [2, 4]

# Reduce - combine elements into a single value
sum_value = uc_list.reduce(lambda acc, x: acc + x, 0)  # 15

# Find - get the first element that matches a condition
first_even = uc_list.find(lambda x: x % 2 == 0)  # 2

# Chain operations
result = uc_list.map(lambda x: x * 2).filter(lambda x: x > 5)  # [6, 8, 10]

Working with Objects

# Get keys
keys = uc_dict.keys()  # ['name', 'age', 'city']

# Get values
values = uc_dict.values()  # ['John', 30, 'New York']

# Clone an object
cloned = uc_dict.clone()  # {'name': 'John', 'age': 30, 'city': 'New York'}

# Extend an object
extended = uc_dict.extend({'country': 'USA'})