Lurker News
Hello HN,

I become active Hacker news at the start of year, its been incredible journey so far. I have learn so many things from computer science to psychology to economics etc. Thanks for all the contribution and best of luck for future. Happy Holidays.

Comments (110) 73 threads

Show all comments

Showing thread 16 of 73

jarcane5 replies#

  map (\x -> chr (x + 32)) [45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1]
mrwnmonm6 replies#
explain :)
hundunpao#
Javascript

  [45, 69, 82, 82, 89, 0, 35, 72, 82, 73, 83, 84, 77, 65, 83, 1].map(function(x){ return String.fromCharCode(x +32)}).join('')
krat0sprakhar#
Copy-paste in your browser console -

    // Merry Christmas
    console.log(
      [45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1]
      .map(function(i) { return i + 32; })
      .map(function(i) { return String.fromCharCode(i); })
      .join("")
    );
zuppy#
I'm to lazy to do the math (substract and look for ascii code), but it should be "Merry Christmas". clue: look where "r" is i the string.
awhitty1 reply#
Python equivalent for convenience:

  map(lambda x: chr (x + 32), [45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1])
Just paste it into a python terminal and run it :)
heinrich59911 reply#
Python 2/3 compatiblity:

    "".join(map(lambda x: chr (x + 32), [45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1]))
adregan#
Or as a list comprehension if that's your thing:

    "".join([chr(x + 32) for x in [45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1]])
jarcane#

  ; Racket version
  (apply string (map (λ (x) (integer->char (+ x 32))) '(45 69 82 82 89 0 35 72 82 73 83 84 77 65 83 1)))
kevinavery#
Scala

  List(45,69,82,82,89,0,35,72,89,73,83,84,77,65,83,1) map (_ + 32 toChar) mkString
sysk1 reply#
What language is this?
malokai2 replies#
Haskell. Here's another way to do it in the same language, using function composition and point-free style.

map (chr . (+32)) [45, 69, 82, 82, 89, 0, 35, 72, 89, 73, 83, 84, 77, 65, 83, 1]

tim333#
Merry Xmas. I thought I'd try Haskell for the same time for Xmas and found I have to download it and import Data.Char first in case anyone else is trying!
peterwwillis#
Or in Perl:

  map{chr$_+32}(45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1)
shorter using pack:

  # shorts
  pack("s*",25933,29298,8313,26691,26994,29811,24941,8563)
  # longs
  pack("l*",1920099661,1749229689,1953720690,561209709)
  # 64-bit
  pack("q*",7512884309367350605,2410377348306397554)
  # hex
  pack("h*",d45627279702348627963747d6163712)
nly#

    #include
    #include
    #include
    using namespace std;

    int main() {
        string s {33,78,68,0,65,0,40,65,80,80,89,0,46,69,87,0,57,69,65,82,0,79,70,0,
                  70,85,78,67,84,73,79,78,65,76,0,67,79,68,69,0,84,79,0,89,79,85,0,
                  84,79,79,12,0,51,73,82,1};
        transform (begin(s), end(s), begin(s), [](char c){ return c + 32; });
        cout << s << endl;
    }
roskilli#
Coffee:

[45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1].map((x) -> String.fromCharCode x+32).join('')

jarcane#
Last one, in old-fashioned style:

  5 FORX=1TO16:READN:N=N+32:?CHR$(N);:NEXTX:DATA45,69,82,82,89,0,35,72,82,73,83,84,77,65,83,1