Square a Number my Way
05AB1E, 7 bytes
þSDg×+O
Try it online!
Explanation
þSDg×+O Implicit input
þ Keep digits
S Get chars
D Duplicate
g Length
× Repeat string(s)
+ Add (implicit input added to all elements)
O Sum
Jelly, 13 12 bytes
fØDẋ€L$ŒV+VS
A monadic link accepting a list of characters (a well-formed decimal number, the single leading zero being a requirement for -1 < n < 1) and returning a number.
Try it online!
14 bytes to accept and return numbers (input limited at +/-10-5 by ŒṘ
): ŒṘfØDẋ€L$ŒV+⁸S
.
How?
fØDẋ€L$ŒV+VS - Link: list of characters e.g. "-0.45"
ØD - yield digit characters "0123456789"
f - filter keep "045"
$ - last two links as a monad:
L - length (number of digit characters) 3
ẋ€ - repeat list for €ach digit ["000","444","555"]
ŒV - evaluate as Python code (vectorises) [0,444,555]
V - evaluate (the input) as Jelly code -0.45
+ - addition (vectorises) [-0.45,443.55,554.55]
S - sum 997.65
Haskell, 59 56 bytes
f s|l<-filter(>'.')s=0.0+sum(read<$>(s<$l)++[c<$l|c<-l])
The input is taken as a string.
Try it online!
How it works
l<-filter(>'.')s -- let l be the string of all the numbers of the input string
f s = 0.0 + sum -- the result is the sum of (add 0.0 to fix the type to float)
read<$> -- turn every string of the following list into a number
s<$l -- length of l times the input string followed by
[c<$l|c<-l] -- length of l times c for each c in l