Posts

Showing posts from June, 2023

Experimenting Recursion in DataWeave - Fibonacci Series

Image
  In various programming languages, recursion is a process in which a method or function calls itself to simplify a complicated problem. Understanding recursive solution sometimes become difficult. Let's try to solve a mathematical problem through recursion with a twist by using DataWeave . The Fibonacci series is a generic use case that recursion can solve. This is a very generic question in programming interviews. Photo by Natalya Letunova on Unsplash What is Fibonacci Series? A Fibonacci series is a set of integers starting with 0 followed by 1, and a series continuing with the sum of the preceding two integers in the sequence. For example, F n =0,1,1,2,3,5,8,13,21,34... Mathematically, F 0 =0 F 1 =1 F n =F (n-1) + F (n-2) Now transforming the above logic in the form of a recursive function to find the nth digit in the Fibonacci series. DataWeave Recursive Function: %dw 2.0 output application/json fun fib_r(n)= if...

Popular posts from this blog

DateTime formatting using xp20:format-dateTime ()

Create Delimited String from XML Nodes and Vice Versa in SOA 12c

Import and Export MDS artifacts in SOA 12c