372 | | let x = ???? |

373 | | let y = ??? |

374 | | plusDoubleVec# x y |

375 | | }}} |

376 | | Using simple lists to achieve the same operation: |

377 | | {{{ |

378 | | let x = [1,2,3,4] |

379 | | let y = [2,3,4,5] |

380 | | zipWith (+) x y |

| 372 | {-# LANGUAGE MagicHash #-} |

| 373 | import GHC.Prim |

| 374 | import GHC.Exts |

| 375 | |

| 376 | getPrimFloat :: Float -> Float# |

| 377 | getPrimFloat f = case f of { F# f -> f } |

| 378 | |

| 379 | main = do |

| 380 | numberString <- getLine |

| 381 | let num = read numberString |

| 382 | let value = getPrimFloat num |

| 383 | numberString2 <- getLine |

| 384 | let num2 = read numberString2 |

| 385 | let value2 = getPrimFloat num2 |

| 386 | |

| 387 | let packedVector1 = pack4FloatOp# value value value value |

| 388 | let packedVector2 = pack4FloatOp# value2 value2 value2 value2 |

| 389 | |

| 390 | let resultVector = multFloatVec4# packedVector1 packedVector2 |

| 391 | |

| 392 | let result = extractFloatVec# resultVector 1 |

| 393 | |

| 394 | let resultFloat = F# result |

| 395 | print resultFloat |

| 396 | }}} |

| 397 | |

| 398 | Using simple lists to achieve the same operation (note that the below is Integer only, I have to modify it to read floats off the command line otherwise a parse error occurs after the reads). |

| 399 | |

| 400 | {{{ |

| 401 | main = do |

| 402 | numberString <- getLine |

| 403 | let value = read numberString |

| 404 | numberString2 <- getLine |

| 405 | let value2 = read numberString2 |

| 406 | |

| 407 | let list1 = [value,value,value,value] |

| 408 | let list2 = [value2,value2,value2,value2] |

| 409 | |

| 410 | let result = zipWith (*) list1 list2 |

| 411 | |

| 412 | print (result !! 1) |