Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Haskell, 31 bytes

Like this Scala answerthis Scala answer, takes input as a sequence of tuples

<hack>

d :: Float c => [(c,c)] -> c d=sqrt.sum.map$(^2).uncurry(-) 

</hack>

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Haskell, 31 bytes

Like this Scala answer, takes input as a sequence of tuples

<hack>

d :: Float c => [(c,c)] -> c d=sqrt.sum.map$(^2).uncurry(-) 

</hack>

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Haskell, 31 bytes

Like this Scala answer, takes input as a sequence of tuples

<hack>

d :: Float c => [(c,c)] -> c d=sqrt.sum.map$(^2).uncurry(-) 

</hack>

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 
added 246 characters in body
Source Link
yyny
  • 1.2k
  • 8
  • 9

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Haskell, 31 bytes

Like this Scala answer, takes input as a sequence of tuples

<hack>

d :: Float c => [(c,c)] -> c d=sqrt.sum.map$(^2).uncurry(-) 

</hack>

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Haskell, 31 bytes

Like this Scala answer, takes input as a sequence of tuples

<hack>

d :: Float c => [(c,c)] -> c d=sqrt.sum.map$(^2).uncurry(-) 

</hack>

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 
added 113 characters in body
Source Link
yyny
  • 1.2k
  • 8
  • 9

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 

Haskell, 46 bytes

d :: Floating c => [c] -> [c] -> c d a=sqrt.sum.map((^2).uncurry(flip(-))).zip a 

Haskell, 35 bytes (By @nimi)

d :: Float c => [c] -> [c] -> c d a=sqrt.sum.zipWith(((^2).).(-))a 

Examples:

Prelude> d [1] [3] 2.0 Prelude> d [1,1] [1,1] 0.0 Prelude> d [1,2,3,4] [5,6,7,8] 8.0 Prelude> d [1.5,2,-5] [-3.45,-13,145] 150.82938208452623 Prelude> d [13.37,2,6,-7] [1.2,3.4,-5.6,7.89] 22.50202213135522 
Source Link
yyny
  • 1.2k
  • 8
  • 9
Loading