(user.#), keytypes: keysOf(object1.users) map (u) -> "index$$": typeOf(u) }]]> (ts > 200)), // allbig: Arrays::every(flights..totalSeats, (ts) -> (ts < 400)), // countem: sizeOf(flights), // allseats: flights..totalSeats, // smallcraftseats: flights..totalSeats Arrays::sumBy (a) -> (if (a<200) a else 0), seatmates: flights..totalSeats Arrays::divideBy 2, triplets: 1 to 17 Arrays::divideBy 3 }]]> String ) = formatter( anInputString ) --- "helloWorld" formatString (inStr) -> lower( inStr replace "World" with " There" ) ]]> (x.one ++ ' ' ++ x.two) //upper( {one:"One", two:"Two"} chain (x) -> (x.one ++ ' ' ++ x.two) ) // //chain (x) -> (x.one ++ ' ' ++ x.two) //chain upper chain( chain( {one:"One", two:"Two"}, (x) -> (x.one ++ ' ' ++ x.two) ), //upper lower ) ]]> k } ) MyMapping::main( {someElement: ["order", "1001"], formatter: lower } ) //MyMapping::main( { incorrect: ["order", "1001"], formatter: lower } ) ]]> anInput //} fun processByType( anInput ) = anInput match { //case a if( a is Array ) -> "input is an Array of size $(sizeOf(a))" case is Array -> "input is an Array of size $(sizeOf(anInput))" //case "SFO" -> "San Francisco" case is Object -> (inputType: "Object") ++ anInput // case is Number -> ($ * dw::modules::FlightsLib::exchangeRate) // as String {format: "#,###.00"} as Number case is Number -> ($ * dw::modules::FlightsLib::exchangeRate) as String {format: "#,###.00"} as Number // else -> anInput //else -> typeOf( anInput ) else -> "input " ++ anInput ++ " is of type " ++ typeOf( anInput ) } --- //americanFlights //overloaded( [1,2]) //overloaded( {one: "One", two: "Two", three: "Three"} ) //overloaded( null ) //processByType( americanFlights ) //processByType( americanFlights[0] ) //processByType(americanFlights[0].ID) processByType("SFO") ]]> readUrl("classpath://" ++ anInputFile ) //) //orElseTry( // () -> readUrl("classpath://examples/" ++ anInputFile ) //) //orElse( // fail("Can't find the file: " ++ anInputFile ++ // " nor /examples/" ++ anInputFile) //) fun readInput(anInputFile) = try ( log( "Could not read in the file, will try in the examples sub-folder", () -> readUrl("classpath://" ++ anInputFile ) ) ) orElseTry( () -> readUrl("classpath://examples/" ++ anInputFile ) ) orElse( fail("Can't find the file: " ++ anInputFile ++ " nor /examples/" ++ anInputFile) ) --- //dw::Runtime::try ( // //readInput("flightsToLAX.json") // () -> readInput("flightsToLAX.json") //) //readInput("flightsToLAX.json") //readInput("noGood.json") readInput(attributes.queryParams.filename default "flightsToLAX.json")]]>