---
title: "Unicode Symbols as Function Names"
description: "Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them."
url: "https://h3manth.com/scribe/unicode-symbols-function-names/"
canonical_url: "https://h3manth.com/scribe/unicode-symbols-function-names/"
markdown_url: "https://h3manth.com/scribe/blog/unicode-symbols-function-names.md"
publishDate: "2011-12-01T00:00:00.000Z"
author: "Hemanth HM"
category: "python"
tags: ["python","bash"]
word_count: 289
reading_time_minutes: 2
x_markdown_tokens: 503
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Unicode Symbols as Function Names

> Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them.

Unicode stings for function/method names is a very rare scenario, but who knows in the near future people might use them daily! [ Too much of an expectation aye? ;) ]

Say : one needs to convert dollars to pounds and writes a method to do so, might name it "dollar2pound", but a code monkey might name it **$2£**

_Below is the result of such a play in few of my favorite programming languages :_

To makes things silly/simple, lets assume our methods takes an integer argument and prints ❤'s those many time.

**First up is BASH [ Simple, undocumented so might stop working soon! ]:**
    
    
    function ❤ () { yes '❤' | head -n$1 | xargs echo; }
    
    # Invoke the function
    ❤ 12
    
    # Bazinga! we got 12 ❤s :)
    ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
    

  
  
**Python's turn :**
    
    
    l={} 
    l['❤'] = lambda x: "❤ "*x
    print l['❤'](12).decode('utf8')
    ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
    

  
**Perl! here it comes! [ Yes you are right, no strict ] :**
    
    
    use utf8;
    *{'❤'} = sub { print '❤ ' x shift; }; 
    ${\'❤'}->(12);  
    ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
    

  
**Ruby [ Don't forget -Ku ] :**
    
    
    #!/usr/bin/ruby -Ku
    def ❤(x)
        puts '❤ '*x;
    end
    ❤(12)
    ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
    

  
**JavaScript FTW!?**
    
    
    String.prototype.repeat = function(n) { 
    return (new Array(n+1)).join(this.valueOf()); 
    };
    this["❤"] = function (x) { return '❤ '.repeat(x); }; 
    this["❤"](12)
    ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤
    

Update :  function Σ() {return [].reduce.call(arguments, function(a,b){return a+b})};

Σ(1,2,3,4)

10 

_So how do you do it in your fav programming languages ;) ?_
